Skip to content

Commit fb46002

Browse files
committed
C++: Fix ThisParameterNode after IR changes
1 parent 7ad45d5 commit fb46002

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,7 @@ class ExprNode extends InstructionNode {
162162
* as `x` in `f(x)` and implicit parameters such as `this` in `x.f()`
163163
*/
164164
class ParameterNode extends InstructionNode {
165-
ParameterNode() {
166-
instr instanceof InitializeParameterInstruction
167-
or
168-
instr instanceof InitializeThisInstruction
169-
}
165+
override InitializeParameterInstruction instr;
170166

171167
/**
172168
* Holds if this node is the parameter of `c` at the specified (zero-based)
@@ -180,7 +176,9 @@ class ParameterNode extends InstructionNode {
180176
* flow graph.
181177
*/
182178
private class ExplicitParameterNode extends ParameterNode {
183-
override InitializeParameterInstruction instr;
179+
ExplicitParameterNode() {
180+
exists(instr.getParameter())
181+
}
184182

185183
override predicate isParameterOf(Function f, int i) { f.getParameter(i) = instr.getParameter() }
186184

@@ -191,7 +189,9 @@ private class ExplicitParameterNode extends ParameterNode {
191189
}
192190

193191
private class ThisParameterNode extends ParameterNode {
194-
override InitializeThisInstruction instr;
192+
ThisParameterNode() {
193+
instr.getIRVariable() instanceof IRThisVariable
194+
}
195195

196196
override predicate isParameterOf(Function f, int i) {
197197
i = -1 and instr.getEnclosingFunction() = f

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ uniqueNodeLocation
1919
missingLocation
2020
| Nodes without location: 4 |
2121
uniqueNodeToString
22-
| lambdas.cpp:2:6:2:9 | (no string representation) | Node should have one toString but has 0. |
2322
missingToString
24-
| Nodes without toString: 1 |
2523
parameterCallable
2624
localFlowIsLocal
2725
compatibleTypesReflexive

cpp/ql/test/library-tests/dataflow/dataflow-tests/test_diff.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
| test.cpp:347:17:347:22 | test.cpp:349:10:349:18 | AST only |
4141
| test.cpp:359:13:359:18 | test.cpp:365:10:365:14 | AST only |
4242
| test.cpp:373:13:373:18 | test.cpp:369:10:369:14 | AST only |
43-
| test.cpp:373:13:373:18 | test.cpp:375:10:375:14 | AST only |
4443
| test.cpp:399:7:399:9 | test.cpp:401:8:401:10 | AST only |
4544
| test.cpp:405:7:405:9 | test.cpp:408:8:408:10 | AST only |
4645
| test.cpp:416:7:416:11 | test.cpp:418:8:418:12 | AST only |

cpp/ql/test/library-tests/dataflow/dataflow-tests/test_ir.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
| test.cpp:266:12:266:12 | x | test.cpp:265:22:265:27 | call to source |
6666
| test.cpp:289:14:289:14 | x | test.cpp:305:17:305:22 | call to source |
6767
| test.cpp:318:7:318:7 | x | test.cpp:314:4:314:9 | call to source |
68+
| test.cpp:375:10:375:14 | field | test.cpp:373:13:373:18 | call to source |
6869
| test.cpp:385:8:385:10 | tmp | test.cpp:382:48:382:54 | source1 |
6970
| test.cpp:392:8:392:10 | tmp | test.cpp:388:53:388:59 | source1 |
7071
| test.cpp:394:10:394:12 | tmp | test.cpp:388:53:388:59 | source1 |

cpp/ql/test/library-tests/dataflow/fields/dataflow-ir-consistency.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ uniqueEnclosingCallable
22
uniqueTypeBound
33
| by_reference.cpp:106:21:106:41 | Chi | Node should have one type bound but has 2. |
44
| by_reference.cpp:126:21:126:40 | Chi | Node should have one type bound but has 2. |
5+
| file://:0:0:0:0 | Chi | Node should have one type bound but has 2. |
56
uniqueTypeRepr
67
uniqueNodeLocation
78
| D.cpp:1:17:1:17 | o | Node should have one location but has 3. |

0 commit comments

Comments
 (0)