Skip to content

Commit 83a8a60

Browse files
committed
Ruby: CFG: consistency query to check that Expr nodes are post-order
1 parent ba89653 commit 83a8a60

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
11
import codeql.ruby.controlflow.internal.ControlFlowGraphImplShared::Consistency
2+
import codeql.ruby.AST
3+
import codeql.ruby.controlflow.internal.ControlFlowGraphImpl
4+
5+
/**
6+
* All `Expr` nodes are `PostOrderTree`s
7+
*/
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
23+
)
24+
}

0 commit comments

Comments
 (0)