Skip to content

Commit 6cce7ef

Browse files
committed
C++: Add CFG test for constexpr_if
1 parent 7c763cc commit 6cce7ef

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
| __va_list_tag::operator= | false | 64 | 64 | operator= |
2+
| __va_list_tag::operator= | false | 70 | 70 | operator= |
3+
| test | false | 121 | 121 | test |
4+
| test | false | 127 | 127 | declaration |
5+
| test | false | 133 | 133 | 1 |
6+
| test | false | 139 | 139 | x |
7+
| test | false | 145 | 145 | 1 |
8+
| test | false | 147 | 147 | ... = ... |
9+
| test | false | 150 | 150 | ExprStmt |
10+
| test | false | 153 | 153 | { ... } |
11+
| test | false | 156 | 156 | x |
12+
| test | false | 162 | 162 | 2 |
13+
| test | false | 164 | 164 | ... = ... |
14+
| test | false | 167 | 167 | ExprStmt |
15+
| test | false | 170 | 170 | { ... } |
16+
| test | false | 173 | 173 | if constexpr (...) ... |
17+
| test | false | 179 | 179 | 0 |
18+
| test | false | 181 | 181 | x |
19+
| test | false | 187 | 187 | 3 |
20+
| test | false | 189 | 189 | ... = ... |
21+
| test | false | 192 | 192 | ExprStmt |
22+
| test | false | 195 | 195 | { ... } |
23+
| test | false | 198 | 198 | if constexpr (...) ... |
24+
| test | false | 201 | 201 | return ... |
25+
| test | false | 204 | 204 | { ... } |
26+
| test | true | 127 | 173 | |
27+
| test | true | 133 | 153 | T |
28+
| test | true | 139 | 147 | |
29+
| test | true | 145 | 139 | |
30+
| test | true | 147 | 198 | |
31+
| test | true | 150 | 145 | |
32+
| test | true | 153 | 150 | |
33+
| test | true | 156 | 164 | |
34+
| test | true | 162 | 156 | |
35+
| test | true | 164 | 198 | |
36+
| test | true | 167 | 162 | |
37+
| test | true | 170 | 167 | |
38+
| test | true | 173 | 133 | |
39+
| test | true | 179 | 201 | F |
40+
| test | true | 181 | 189 | |
41+
| test | true | 187 | 181 | |
42+
| test | true | 189 | 201 | |
43+
| test | true | 192 | 187 | |
44+
| test | true | 195 | 192 | |
45+
| test | true | 198 | 179 | |
46+
| test | true | 201 | 121 | |
47+
| test | true | 204 | 127 | |
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// query-type: graph
2+
import cpp
3+
4+
class DestructorCallEnhanced extends DestructorCall {
5+
override string toString() {
6+
if exists(this.getQualifier().(VariableAccess).getTarget().getName())
7+
then result = "call to " + this.getQualifier().(VariableAccess).getTarget().getName() + "." + this.getTarget().getName()
8+
else result = super.toString()
9+
}
10+
}
11+
12+
string scope(ControlFlowNode x) {
13+
if exists(x.getControlFlowScope().getQualifiedName())
14+
then result = x.getControlFlowScope().getQualifiedName()
15+
else result = "<no scope>"
16+
}
17+
18+
predicate isNode(boolean isEdge, ControlFlowNode x, ControlFlowNode y, string label) {
19+
isEdge = false and x = y and label = x.toString()
20+
}
21+
22+
predicate isSuccessor(boolean isEdge, ControlFlowNode x, ControlFlowNode y, string label) {
23+
exists(string truelabel, string falselabel |
24+
isEdge = true
25+
and x.getASuccessor() = y
26+
and if x.getATrueSuccessor() = y then truelabel = "T" else truelabel = ""
27+
and if x.getAFalseSuccessor() = y then falselabel = "F" else falselabel = ""
28+
and label = truelabel + falselabel)
29+
}
30+
31+
from boolean isEdge, ControlFlowNode x, ControlFlowNode y, string label
32+
where isNode(isEdge, x, y, label) or isSuccessor(isEdge, x, y, label)
33+
select scope(x), isEdge, x, y, label
34+

0 commit comments

Comments
 (0)