Skip to content

Commit d299380

Browse files
committed
Rust: Enable CFG consistency checks
1 parent f428fdc commit d299380

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

csharp/ql/consistency-queries/CfgConsistency.ql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,3 @@ query predicate preBasicBlockConsistency(ControlFlowElement cfe1, ControlFlowEle
6161
bbIntraSuccInconsistency(cfe1, cfe2) and
6262
s = "intra succ inconsistency"
6363
}
64-
65-
query predicate multipleToString(Node n, string s) {
66-
s = strictconcat(n.toString(), ",") and
67-
strictcount(n.toString()) > 1
68-
}

ruby/ql/consistency-queries/CfgConsistency.ql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,3 @@ query predicate nonPostOrderExpr(Expr e, string cls) {
1919
c instanceof NormalCompletion
2020
)
2121
}
22-
23-
query predicate multipleToString(CfgNode n, string s) {
24-
s = strictconcat(n.toString(), ",") and
25-
strictcount(n.toString()) > 1
26-
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import rust
2+
import codeql.rust.controlflow.internal.ControlFlowGraphImpl::Consistency
3+
import codeql.rust.controlflow.internal.ControlFlowGraphImpl as CfgImpl
4+
import codeql.rust.controlflow.internal.Completion
5+
6+
/**
7+
* All `Expr` nodes are `PostOrderTree`s
8+
*/
9+
query predicate nonPostOrderExpr(Expr e, string cls) {
10+
cls = e.getPrimaryQlClasses() and
11+
not e instanceof LetExpr and
12+
not e instanceof LogicalAndExpr and // todo
13+
not e instanceof LogicalOrExpr and
14+
exists(AstNode last, Completion c |
15+
CfgImpl::last(e, last, c) and
16+
last != e and
17+
c instanceof NormalCompletion
18+
)
19+
}

rust/ql/consistency-queries/Placeholder.ql

Lines changed: 0 additions & 3 deletions
This file was deleted.

shared/controlflow/codeql/controlflow/Cfg.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,5 +1386,10 @@ module Make<LocationSig Location, InputSig<Location> Input> {
13861386
ord = sk.getListOrder() and
13871387
strictcount(sk.getListOrder()) > 1
13881388
}
1389+
1390+
query predicate multipleToString(Node n, string s) {
1391+
s = strictconcat(n.toString(), ",") and
1392+
strictcount(n.toString()) > 1
1393+
}
13891394
}
13901395
}

0 commit comments

Comments
 (0)