Skip to content

Commit 560413f

Browse files
committed
Address comments
1 parent 83a8a60 commit 560413f

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import codeql.ruby.controlflow.internal.ControlFlowGraphImplShared::Consistency
22
import codeql.ruby.AST
3+
import codeql.ruby.controlflow.internal.Completion
34
import codeql.ruby.controlflow.internal.ControlFlowGraphImpl
45

56
/**
67
* All `Expr` nodes are `PostOrderTree`s
78
*/
8-
query predicate nonPostOrderExprTypes(string cls) {
9-
exists(Expr e |
10-
e instanceof ControlFlowTree and
11-
not exists(e.getDesugared()) and
12-
cls = e.getAPrimaryQlClass() and
13-
not e instanceof PostOrderTree and
14-
not e instanceof LeafTree
15-
)
16-
or
17-
exists(Expr e |
18-
e instanceof ControlFlowTree and
19-
e = any(AstNode x).getDesugared() and
20-
cls = e.getAPrimaryQlClass() and
21-
not e instanceof PostOrderTree and
22-
not e instanceof LeafTree
9+
query predicate nonPostOrderExpr(Expr e, string cls) {
10+
cls = e.getPrimaryQlClasses() and
11+
not exists(e.getDesugared()) and
12+
not e instanceof BeginExpr and
13+
not e instanceof Namespace and
14+
not e instanceof Toplevel and
15+
exists(AstNode last, Completion c |
16+
last(e, last, c) and
17+
last != e and
18+
c instanceof NormalCompletion
2319
)
2420
}

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ module Trees {
399399
)
400400
or
401401
succ = this and
402+
c instanceof NormalCompletion and
402403
(
403404
last(this.getValue(), pred, c) and not exists(this.getABranch())
404405
or
@@ -442,12 +443,12 @@ module Trees {
442443
)
443444
or
444445
succ = this and
446+
c instanceof NormalCompletion and
445447
(
446448
last(this.getABranch(), pred, c) and
447449
not c.(MatchingCompletion).getValue() = false
448450
or
449-
last(this.getElseBranch(), pred, c) and
450-
c instanceof NormalCompletion
451+
last(this.getElseBranch(), pred, c)
451452
)
452453
}
453454
}
@@ -1166,6 +1167,7 @@ module Trees {
11661167
)
11671168
or
11681169
last(this.getHandler(), pred, c) and
1170+
c instanceof NormalCompletion and
11691171
succ = this
11701172
}
11711173
}

0 commit comments

Comments
 (0)