Skip to content

Commit 791f591

Browse files
committed
C++: Fix multiple getLocation consistency error in use-use dataflow
1 parent 55da325 commit 791f591

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private class Node0 extends Node, TNode0 {
390390

391391
override DataFlowType getType() { result = node.getType() }
392392

393-
final override Location getLocationImpl() { result = node.getLocationImpl() }
393+
override Location getLocationImpl() { result = node.getLocationImpl() }
394394

395395
override string toStringImpl() {
396396
// This predicate is overridden in subclasses. This default implementation
@@ -413,6 +413,8 @@ class InstructionNode extends Node0 {
413413
/** Gets the instruction corresponding to this node. */
414414
Instruction getInstruction() { result = instr }
415415

416+
override Location getLocationImpl() { result = instr.getAst().getLocation() }
417+
416418
override string toStringImpl() {
417419
if instr.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable
418420
then result = "this"
@@ -432,6 +434,8 @@ class OperandNode extends Node, Node0 {
432434
/** Gets the operand corresponding to this node. */
433435
Operand getOperand() { result = op }
434436

437+
override Location getLocationImpl() { result = op.getDef().getAst().getLocation() }
438+
435439
override string toStringImpl() {
436440
if op.getDef().(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable
437441
then result = "this"

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
uniqueEnclosingCallable
22
uniqueType
33
uniqueNodeLocation
4-
| cpp11.cpp:28:21:28:21 | (__range) | Node should have one location but has 2. |
5-
| cpp11.cpp:28:21:28:21 | (__range) | Node should have one location but has 2. |
6-
| file://:0:0:0:0 | (__range) | Node should have one location but has 2. |
7-
| file://:0:0:0:0 | (__range) | Node should have one location but has 2. |
8-
| file://:0:0:0:0 | (__range) | Node should have one location but has 2. |
9-
| file://:0:0:0:0 | (__range) | Node should have one location but has 2. |
104
| file://:0:0:0:0 | (unnamed parameter 2) | Node should have one location but has 0. |
115
| file://:0:0:0:0 | (unnamed parameter 2) | Node should have one location but has 0. |
126
| file://:0:0:0:0 | (unnamed parameter 2) | Node should have one location but has 0. |
@@ -19,12 +13,6 @@ uniqueNodeLocation
1913
| file://:0:0:0:0 | (unnamed parameter 2) indirection | Node should have one location but has 0. |
2014
| file://:0:0:0:0 | (unnamed parameter 2) indirection | Node should have one location but has 0. |
2115
| file://:0:0:0:0 | (unnamed parameter 2) indirection | Node should have one location but has 0. |
22-
| file://:0:0:0:0 | this | Node should have one location but has 2. |
23-
| file://:0:0:0:0 | this | Node should have one location but has 2. |
24-
| ir.cpp:756:8:756:8 | this | Node should have one location but has 2. |
25-
| ir.cpp:765:8:765:8 | this | Node should have one location but has 2. |
26-
| stream_it.cpp:11:16:11:16 | (__range) | Node should have one location but has 2. |
27-
| stream_it.cpp:11:16:11:16 | (__range) | Node should have one location but has 2. |
2816
missingLocation
2917
| Nodes without location: 12 |
3018
uniqueNodeToString

0 commit comments

Comments
 (0)