Rust: Enable CFG consistency checks

This commit is contained in:
Tom Hvitved
2024-09-24 13:40:08 +02:00
parent f428fdc57c
commit d299380a5a
5 changed files with 24 additions and 13 deletions

View File

@@ -61,8 +61,3 @@ query predicate preBasicBlockConsistency(ControlFlowElement cfe1, ControlFlowEle
bbIntraSuccInconsistency(cfe1, cfe2) and
s = "intra succ inconsistency"
}
query predicate multipleToString(Node n, string s) {
s = strictconcat(n.toString(), ",") and
strictcount(n.toString()) > 1
}

View File

@@ -19,8 +19,3 @@ query predicate nonPostOrderExpr(Expr e, string cls) {
c instanceof NormalCompletion
)
}
query predicate multipleToString(CfgNode n, string s) {
s = strictconcat(n.toString(), ",") and
strictcount(n.toString()) > 1
}

View File

@@ -0,0 +1,19 @@
import rust
import codeql.rust.controlflow.internal.ControlFlowGraphImpl::Consistency
import codeql.rust.controlflow.internal.ControlFlowGraphImpl as CfgImpl
import codeql.rust.controlflow.internal.Completion
/**
* All `Expr` nodes are `PostOrderTree`s
*/
query predicate nonPostOrderExpr(Expr e, string cls) {
cls = e.getPrimaryQlClasses() and
not e instanceof LetExpr and
not e instanceof LogicalAndExpr and // todo
not e instanceof LogicalOrExpr and
exists(AstNode last, Completion c |
CfgImpl::last(e, last, c) and
last != e and
c instanceof NormalCompletion
)
}

View File

@@ -1,3 +0,0 @@
from boolean b
where b = true and b = false
select b

View File

@@ -1386,5 +1386,10 @@ module Make<LocationSig Location, InputSig<Location> Input> {
ord = sk.getListOrder() and
strictcount(sk.getListOrder()) > 1
}
query predicate multipleToString(Node n, string s) {
s = strictconcat(n.toString(), ",") and
strictcount(n.toString()) > 1
}
}
}