Skip to content

Commit 1ee5d3e

Browse files
committed
Move ParameterPosition etc to DataflowDispatch.qll
1 parent e582920 commit 1ee5d3e

File tree

2 files changed

+23
-34
lines changed

2 files changed

+23
-34
lines changed

go/ql/lib/semmle/go/dataflow/internal/DataFlowDispatch.qll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,25 @@ predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable f) { non
108108
* restricted to those `call`s for which a context might make a difference.
109109
*/
110110
DataFlowCallable viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) { none() }
111+
112+
/** Holds if `i` is a valid parameter position. */
113+
predicate parameterPosition(int i) {
114+
i = [-1 .. any(DataFlowCallable c).getType().getNumParameter()]
115+
}
116+
117+
/** Gets the parameter position of the instance parameter. */
118+
int instanceParameterPosition() { result = -1 }
119+
120+
/** A parameter position represented by an integer. */
121+
class ParameterPosition extends int {
122+
ParameterPosition() { parameterPosition(this) }
123+
}
124+
125+
/** An argument position represented by an integer. */
126+
class ArgumentPosition extends int {
127+
ArgumentPosition() { parameterPosition(this) }
128+
}
129+
130+
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
131+
pragma[inline]
132+
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
private import go
6+
private import DataFlowDispatch
67
private import DataFlowPrivate
78
private import DataFlowUtil
89
private import FlowSummaryImpl::Private
@@ -18,40 +19,6 @@ class SummarizedCallableBase = Callable;
1819

1920
DataFlowCallable inject(SummarizedCallable c) { result.asCallable() = c }
2021

21-
/** Holds if `i` is a valid parameter position. */
22-
predicate parameterPosition(int i) {
23-
i = [-1 .. any(DataFlowCallable c).getType().getNumParameter()]
24-
}
25-
26-
/** Gets the parameter position of the instance parameter. */
27-
int instanceParameterPosition() { result = -1 }
28-
29-
/** A parameter position represented by an integer. */
30-
class ParameterPosition extends int {
31-
ParameterPosition() { parameterPosition(this) }
32-
}
33-
34-
/** An argument position represented by an integer. */
35-
class ArgumentPosition extends int {
36-
ArgumentPosition() { parameterPosition(this) }
37-
}
38-
39-
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
40-
pragma[inline]
41-
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
42-
43-
/**
44-
* Holds if `arg` is an argument of `call` with an argument position that matches
45-
* parameter position `ppos`.
46-
*/
47-
pragma[noinline]
48-
predicate argumentPositionMatch(DataFlowCall call, ArgNode arg, ParameterPosition ppos) {
49-
exists(ArgumentPosition apos |
50-
arg.argumentOf(call, apos) and
51-
parameterMatch(ppos, apos)
52-
)
53-
}
54-
5522
/** Gets the textual representation of a parameter position in the format used for flow summaries. */
5623
string getParameterPositionCsv(ParameterPosition pos) { result = pos.toString() }
5724

0 commit comments

Comments
 (0)