Skip to content

Commit b8ae874

Browse files
authored
Merge pull request #4182 from github/igfoo/cfg
C++: Remove some remnants of the extractor CFG
2 parents aa4237c + 8c7431c commit b8ae874

File tree

9 files changed

+5746
-1879
lines changed

9 files changed

+5746
-1879
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ControlFlowNode extends Locatable, ControlFlowNodeBase {
6565
* taken when this expression is true.
6666
*/
6767
ControlFlowNode getATrueSuccessor() {
68-
truecond_base(this, result) and
68+
qlCFGTrueSuccessor(this, result) and
6969
result = getASuccessor()
7070
}
7171

@@ -74,7 +74,7 @@ class ControlFlowNode extends Locatable, ControlFlowNodeBase {
7474
* taken when this expression is false.
7575
*/
7676
ControlFlowNode getAFalseSuccessor() {
77-
falsecond_base(this, result) and
77+
qlCFGFalseSuccessor(this, result) and
7878
result = getASuccessor()
7979
}
8080

@@ -95,18 +95,20 @@ import ControlFlowGraphPublic
9595
class ControlFlowNodeBase extends ElementBase, @cfgnode { }
9696

9797
/**
98+
* DEPRECATED: Use `ControlFlowNode.getATrueSuccessor()` instead.
9899
* Holds when `n2` is a control-flow node such that the control-flow
99100
* edge `(n1, n2)` may be taken when `n1` is an expression that is true.
100101
*/
101-
predicate truecond_base(ControlFlowNodeBase n1, ControlFlowNodeBase n2) {
102+
deprecated predicate truecond_base(ControlFlowNodeBase n1, ControlFlowNodeBase n2) {
102103
qlCFGTrueSuccessor(n1, n2)
103104
}
104105

105106
/**
107+
* DEPRECATED: Use `ControlFlowNode.getAFalseSuccessor()` instead.
106108
* Holds when `n2` is a control-flow node such that the control-flow
107109
* edge `(n1, n2)` may be taken when `n1` is an expression that is false.
108110
*/
109-
predicate falsecond_base(ControlFlowNodeBase n1, ControlFlowNodeBase n2) {
111+
deprecated predicate falsecond_base(ControlFlowNodeBase n1, ControlFlowNodeBase n2) {
110112
qlCFGFalseSuccessor(n1, n2)
111113
}
112114

@@ -134,7 +136,7 @@ abstract class AdditionalControlFlowEdge extends ControlFlowNodeBase {
134136
/**
135137
* Holds if there is a control-flow edge from `source` to `target` in either
136138
* the extractor-generated control-flow graph or in a subclass of
137-
* `AdditionalControlFlowEdge`. Use this relation instead of `successors`.
139+
* `AdditionalControlFlowEdge`. Use this relation instead of `qlCFGSuccessor`.
138140
*/
139141
predicate successors_extended(ControlFlowNodeBase source, ControlFlowNodeBase target) {
140142
qlCFGSuccessor(source, target)

cpp/ql/src/semmle/code/cpp/controlflow/internal/CFG.qll

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,6 @@ private module Cached {
13761376
/**
13771377
* Holds if `n2` is a successor of `n1` in the CFG. This includes also
13781378
* true-successors and false-successors.
1379-
*
1380-
* This corresponds to the old `successors` dbscheme relation.
13811379
*/
13821380
cached
13831381
predicate qlCFGSuccessor(Node n1, Node n2) {
@@ -1390,9 +1388,8 @@ private module Cached {
13901388
}
13911389

13921390
/**
1393-
* Holds if `n2` is a true-successor of `n1` in the CFG.
1394-
*
1395-
* This corresponds to the old `truecond` dbscheme relation.
1391+
* Holds if `n2` is a control-flow node such that the control-flow
1392+
* edge `(n1, n2)` may be taken when `n1` is an expression that is true.
13961393
*/
13971394
cached
13981395
predicate qlCFGTrueSuccessor(Node n1, Node n2) {
@@ -1401,9 +1398,8 @@ private module Cached {
14011398
}
14021399

14031400
/**
1404-
* Holds if `n2` is a false-successor of `n1` in the CFG.
1405-
*
1406-
* This corresponds to the old `falsecond` dbscheme relation.
1401+
* Holds if `n2` is a control-flow node such that the control-flow
1402+
* edge `(n1, n2)` may be taken when `n1` is an expression that is false.
14071403
*/
14081404
cached
14091405
predicate qlCFGFalseSuccessor(Node n1, Node n2) {

cpp/ql/src/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import cpp
22
private import PrimitiveBasicBlocks
3+
private import semmle.code.cpp.controlflow.internal.CFG
34

45
private class Node = ControlFlowNodeBase;
56

@@ -153,17 +154,17 @@ private predicate nonAnalyzableFunction(Function f) {
153154
*/
154155
private predicate impossibleFalseEdge(Expr condition, Node succ) {
155156
conditionAlwaysTrue(condition) and
156-
falsecond_base(condition, succ) and
157-
not truecond_base(condition, succ)
157+
qlCFGFalseSuccessor(condition, succ) and
158+
not qlCFGTrueSuccessor(condition, succ)
158159
}
159160

160161
/**
161162
* If a condition is provably false, then control-flow edges to its true successors are impossible.
162163
*/
163164
private predicate impossibleTrueEdge(Expr condition, Node succ) {
164165
conditionAlwaysFalse(condition) and
165-
truecond_base(condition, succ) and
166-
not falsecond_base(condition, succ)
166+
qlCFGTrueSuccessor(condition, succ) and
167+
not qlCFGFalseSuccessor(condition, succ)
167168
}
168169

169170
/**
@@ -863,9 +864,9 @@ library class ConditionEvaluator extends ExprEvaluator {
863864
ConditionEvaluator() { this = 0 }
864865

865866
override predicate interesting(Expr e) {
866-
falsecond_base(e, _)
867+
qlCFGFalseSuccessor(e, _)
867868
or
868-
truecond_base(e, _)
869+
qlCFGTrueSuccessor(e, _)
869870
}
870871
}
871872

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,20 +1935,6 @@ stmtparents(
19351935
ishandler(unique int block: @stmt_block ref);
19361936

19371937
@cfgnode = @stmt | @expr | @function | @initialiser ;
1938-
successors(
1939-
int from: @cfgnode ref,
1940-
int to: @cfgnode ref
1941-
);
1942-
1943-
truecond(
1944-
unique int from: @cfgnode ref,
1945-
int to: @cfgnode ref
1946-
);
1947-
1948-
falsecond(
1949-
unique int from: @cfgnode ref,
1950-
int to: @cfgnode ref
1951-
);
19521938

19531939
stmt_decl_bind(
19541940
int stmt: @stmt_decl ref,

0 commit comments

Comments
 (0)