Skip to content

Commit 8bed418

Browse files
committed
C++: enable the QL-based CFG code
1 parent 3313af5 commit 8bed418

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

change-notes/1.23/analysis-cpp.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ The following changes in version 1.23 affect C/C++ analysis in all applications.
4242
clarity (e.g. `isOutReturnPointer()` to `isReturnValueDeref()`). The existing member predicates
4343
have been deprecated, and will be removed in a future release. Code that uses the old member
4444
predicates should be updated to use the corresponding new member predicate.
45+
* The control-flow graph is now computed in QL, not in the extractor. This can
46+
lead to regressions (or improvements) in how queries are optimized because
47+
optimization in QL relies on static size estimates, and the control-flow edge
48+
relations will now have different size estimates than before.

cpp/ql/src/semmle/code/cpp/controlflow/ControlFlowGraph.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import cpp
22
import BasicBlocks
33
private import semmle.code.cpp.controlflow.internal.ConstantExprs
4+
private import semmle.code.cpp.controlflow.internal.CFG
45

56
/**
67
* A control-flow node is either a statement or an expression; in addition,
@@ -86,11 +87,11 @@ import ControlFlowGraphPublic
8687
class ControlFlowNodeBase extends ElementBase, @cfgnode { }
8788

8889
predicate truecond_base(ControlFlowNodeBase n1, ControlFlowNodeBase n2) {
89-
truecond(unresolveElement(n1), unresolveElement(n2))
90+
qlCFGTrueSuccessor(n1, n2)
9091
}
9192

9293
predicate falsecond_base(ControlFlowNodeBase n1, ControlFlowNodeBase n2) {
93-
falsecond(unresolveElement(n1), unresolveElement(n2))
94+
qlCFGFalseSuccessor(n1, n2)
9495
}
9596

9697
/**
@@ -120,7 +121,7 @@ abstract class AdditionalControlFlowEdge extends ControlFlowNodeBase {
120121
* `AdditionalControlFlowEdge`. Use this relation instead of `successors`.
121122
*/
122123
predicate successors_extended(ControlFlowNodeBase source, ControlFlowNodeBase target) {
123-
successors(unresolveElement(source), unresolveElement(target))
124+
qlCFGSuccessor(source, target)
124125
or
125126
source.(AdditionalControlFlowEdge).getAnEdgeTarget() = target
126127
}

0 commit comments

Comments
 (0)