diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll index 59f2a72d452..56523bb01a3 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll @@ -390,7 +390,7 @@ private class Node0 extends Node, TNode0 { override DataFlowType getType() { result = node.getType() } - final override Location getLocationImpl() { result = node.getLocationImpl() } + override Location getLocationImpl() { result = node.getLocationImpl() } override string toStringImpl() { // This predicate is overridden in subclasses. This default implementation @@ -413,6 +413,8 @@ class InstructionNode extends Node0 { /** Gets the instruction corresponding to this node. */ Instruction getInstruction() { result = instr } + override Location getLocationImpl() { result = instr.getAst().getLocation() } + override string toStringImpl() { if instr.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable then result = "this" @@ -432,6 +434,8 @@ class OperandNode extends Node, Node0 { /** Gets the operand corresponding to this node. */ Operand getOperand() { result = op } + override Location getLocationImpl() { result = op.getDef().getAst().getLocation() } + override string toStringImpl() { if op.getDef().(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable then result = "this" diff --git a/cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected b/cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected index ffe98d6c290..59353338b32 100644 --- a/cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected +++ b/cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected @@ -1,12 +1,6 @@ uniqueEnclosingCallable uniqueType uniqueNodeLocation -| cpp11.cpp:28:21:28:21 | (__range) | Node should have one location but has 2. | -| cpp11.cpp:28:21:28:21 | (__range) | Node should have one location but has 2. | -| file://:0:0:0:0 | (__range) | Node should have one location but has 2. | -| file://:0:0:0:0 | (__range) | Node should have one location but has 2. | -| file://:0:0:0:0 | (__range) | Node should have one location but has 2. | -| file://:0:0:0:0 | (__range) | Node should have one location but has 2. | | file://:0:0:0:0 | (unnamed parameter 2) | Node should have one location but has 0. | | file://:0:0:0:0 | (unnamed parameter 2) | Node should have one location but has 0. | | file://:0:0:0:0 | (unnamed parameter 2) | Node should have one location but has 0. | @@ -19,12 +13,6 @@ uniqueNodeLocation | file://:0:0:0:0 | (unnamed parameter 2) indirection | Node should have one location but has 0. | | file://:0:0:0:0 | (unnamed parameter 2) indirection | Node should have one location but has 0. | | file://:0:0:0:0 | (unnamed parameter 2) indirection | Node should have one location but has 0. | -| file://:0:0:0:0 | this | Node should have one location but has 2. | -| file://:0:0:0:0 | this | Node should have one location but has 2. | -| ir.cpp:756:8:756:8 | this | Node should have one location but has 2. | -| ir.cpp:765:8:765:8 | this | Node should have one location but has 2. | -| stream_it.cpp:11:16:11:16 | (__range) | Node should have one location but has 2. | -| stream_it.cpp:11:16:11:16 | (__range) | Node should have one location but has 2. | missingLocation | Nodes without location: 12 | uniqueNodeToString