Skip to content

Commit 7437de2

Browse files
committed
C++: Fix issue where 'getEnclosingCallable' didn't exist for some globals.
1 parent 2203eb6 commit 7437de2

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class PostFieldUpdateNode extends TPostFieldUpdateNode, PartialDefinitionNode {
461461

462462
PostFieldUpdateNode() { this = TPostFieldUpdateNode(fieldAddress, indirectionIndex) }
463463

464-
override Function getFunction() { result = fieldAddress.getUse().getEnclosingFunction() }
464+
override Declaration getFunction() { result = fieldAddress.getUse().getEnclosingFunction() }
465465

466466
override Declaration getEnclosingCallable() { result = this.getFunction() }
467467

@@ -543,7 +543,7 @@ class SideEffectOperandNode extends Node, IndirectOperand {
543543

544544
override Declaration getEnclosingCallable() { result = this.getFunction() }
545545

546-
override Function getFunction() { result = call.getEnclosingFunction() }
546+
override Declaration getFunction() { result = call.getEnclosingFunction() }
547547

548548
Expr getArgument() { result = call.getArgument(argumentIndex).getUnconvertedResultExpression() }
549549
}
@@ -629,7 +629,7 @@ class IndirectParameterNode extends Node, IndirectInstruction {
629629

630630
override Declaration getEnclosingCallable() { result = this.getFunction() }
631631

632-
override Function getFunction() { result = this.getInstruction().getEnclosingFunction() }
632+
override Declaration getFunction() { result = this.getInstruction().getEnclosingFunction() }
633633

634634
override string toStringImpl() {
635635
result = this.getParameter().toString() + " indirection"
@@ -702,7 +702,7 @@ class IndirectArgumentOutNode extends Node, TIndirectArgumentOutNode, PartialDef
702702

703703
override Declaration getEnclosingCallable() { result = this.getFunction() }
704704

705-
override Function getFunction() { result = this.getCallInstruction().getEnclosingFunction() }
705+
override Declaration getFunction() { result = this.getCallInstruction().getEnclosingFunction() }
706706

707707
override Node getPreUpdateNode() { hasOperandAndIndex(result, operand, indirectionIndex) }
708708

@@ -847,7 +847,7 @@ class RawIndirectOperand extends Node, TRawIndirectOperand {
847847
/** Gets the underlying indirection index. */
848848
int getIndirectionIndex() { result = indirectionIndex }
849849

850-
override Function getFunction() { result = this.getOperand().getDef().getEnclosingFunction() }
850+
override Declaration getFunction() { result = this.getOperand().getDef().getEnclosingFunction() }
851851

852852
override Declaration getEnclosingCallable() { result = this.getFunction() }
853853

@@ -888,7 +888,7 @@ class FinalParameterNode extends Node, TFinalParameterNode {
888888
/** Gets the argument index associated with this final use. */
889889
final int getArgumentIndex() { result = p.getIndex() }
890890

891-
override Function getFunction() { result = p.getFunction() }
891+
override Declaration getFunction() { result = p.getFunction() }
892892

893893
override Declaration getEnclosingCallable() { result = this.getFunction() }
894894

@@ -945,7 +945,7 @@ class RawIndirectInstruction extends Node, TRawIndirectInstruction {
945945
/** Gets the underlying indirection index. */
946946
int getIndirectionIndex() { result = indirectionIndex }
947947

948-
override Function getFunction() { result = this.getInstruction().getEnclosingFunction() }
948+
override Declaration getFunction() { result = this.getInstruction().getEnclosingFunction() }
949949

950950
override Declaration getEnclosingCallable() { result = this.getFunction() }
951951

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
uniqueEnclosingCallable
2-
| globals.cpp:9:5:9:19 | flowTestGlobal1 indirection | Node should have one enclosing callable but has 0. |
3-
| globals.cpp:9:5:9:19 | flowTestGlobal1 indirection | Node should have one enclosing callable but has 0. |
4-
| globals.cpp:16:12:16:26 | flowTestGlobal2 indirection | Node should have one enclosing callable but has 0. |
5-
| globals.cpp:16:12:16:26 | flowTestGlobal2 indirection | Node should have one enclosing callable but has 0. |
62
uniqueType
73
uniqueNodeLocation
84
missingLocation

0 commit comments

Comments
 (0)