Skip to content

Commit 9cb8edb

Browse files
committed
C++: Change 'Function' to 'Declaration' in a few places to handle enclosing callables being fields.
1 parent eb35fa0 commit 9cb8edb

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ class IndirectArgumentOutNode extends PostUpdateNodeImpl {
11241124
/**
11251125
* Gets the `Function` that the call targets, if this is statically known.
11261126
*/
1127-
Function getStaticCallTarget() { result = this.getCallInstruction().getStaticCallTarget() }
1127+
Declaration getStaticCallTarget() { result = this.getCallInstruction().getStaticCallTarget() }
11281128

11291129
override string toStringImpl() {
11301130
exists(string prefix | if indirectionIndex > 0 then prefix = "" else prefix = "pointer to " |
@@ -1628,7 +1628,7 @@ abstract private class AbstractParameterNode extends Node {
16281628
* implicit `this` parameter is considered to have position `-1`, and
16291629
* pointer-indirection parameters are at further negative positions.
16301630
*/
1631-
predicate isSourceParameterOf(Function f, ParameterPosition pos) { none() }
1631+
predicate isSourceParameterOf(Declaration f, ParameterPosition pos) { none() }
16321632

16331633
/**
16341634
* Holds if this node is the parameter of `sc` at the specified position. The
@@ -1711,7 +1711,7 @@ private class IndirectInstructionParameterNode extends AbstractIndirectParameter
17111711

17121712
override Declaration getFunction() { result = init.getEnclosingFunction() }
17131713

1714-
override predicate isSourceParameterOf(Function f, ParameterPosition pos) {
1714+
override predicate isSourceParameterOf(Declaration f, ParameterPosition pos) {
17151715
this.getFunction() = f and
17161716
exists(int argumentIndex, int indirectionIndex |
17171717
indirectPositionHasArgumentIndexAndIndex(pos, argumentIndex, indirectionIndex) and
@@ -1744,7 +1744,7 @@ abstract class InstructionDirectParameterNode extends InstructionNode, AbstractD
17441744

17451745
override Parameter getParameter() { result = instr.getParameter() }
17461746

1747-
override predicate isSourceParameterOf(Function f, ParameterPosition pos) {
1747+
override predicate isSourceParameterOf(Declaration f, ParameterPosition pos) {
17481748
this.getFunction() = f and
17491749
exists(int argumentIndex |
17501750
pos.(DirectPosition).getArgumentIndex() = argumentIndex and
@@ -1789,9 +1789,9 @@ private class DirectBodyLessParameterNode extends AbstractExplicitParameterNode,
17891789
{
17901790
DirectBodyLessParameterNode() { indirectionIndex = 0 }
17911791

1792-
override predicate isSourceParameterOf(Function f, ParameterPosition pos) {
1792+
override predicate isSourceParameterOf(Declaration f, ParameterPosition pos) {
17931793
this.getFunction() = f and
1794-
f.getParameter(pos.(DirectPosition).getArgumentIndex()) = p
1794+
f.(Function).getParameter(pos.(DirectPosition).getArgumentIndex()) = p
17951795
}
17961796

17971797
override Parameter getParameter() { result = p }
@@ -1802,10 +1802,10 @@ private class IndirectBodyLessParameterNode extends AbstractIndirectParameterNod
18021802
{
18031803
IndirectBodyLessParameterNode() { not this instanceof DirectBodyLessParameterNode }
18041804

1805-
override predicate isSourceParameterOf(Function f, ParameterPosition pos) {
1805+
override predicate isSourceParameterOf(Declaration f, ParameterPosition pos) {
18061806
exists(int argumentPosition |
18071807
this.getFunction() = f and
1808-
f.getParameter(argumentPosition) = p and
1808+
f.(Function).getParameter(argumentPosition) = p and
18091809
indirectPositionHasArgumentIndexAndIndex(pos, argumentPosition, indirectionIndex)
18101810
)
18111811
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ class DataFlowCall extends TDataFlowCall {
11701170
/**
11711171
* Gets the `Function` that the call targets, if this is statically known.
11721172
*/
1173-
Function getStaticCallSourceTarget() { none() }
1173+
Declaration getStaticCallSourceTarget() { none() }
11741174

11751175
/**
11761176
* Gets the target of this call. We use the following strategy for deciding
@@ -1182,7 +1182,7 @@ class DataFlowCall extends TDataFlowCall {
11821182
* whether is it manual or generated.
11831183
*/
11841184
final DataFlowCallable getStaticCallTarget() {
1185-
exists(Function target | target = this.getStaticCallSourceTarget() |
1185+
exists(Declaration target | target = this.getStaticCallSourceTarget() |
11861186
// Don't use the source callable if there is a manual model for the
11871187
// target
11881188
not exists(SummarizedCallable sc |
@@ -1242,7 +1242,7 @@ private class NormalCall extends DataFlowCall, TNormalCall {
12421242

12431243
override CallTargetOperand getCallTargetOperand() { result = call.getCallTargetOperand() }
12441244

1245-
override Function getStaticCallSourceTarget() { result = call.getStaticCallTarget() }
1245+
override Declaration getStaticCallSourceTarget() { result = call.getStaticCallTarget() }
12461246

12471247
override ArgumentOperand getArgumentOperand(int index) { result = call.getArgumentOperand(index) }
12481248

0 commit comments

Comments
 (0)