@@ -148,23 +148,31 @@ methods, constructors, lambdas, etc.). It can also be useful to represent
148
148
` DataFlowCall ` as an IPA type if implicit calls need to be modelled. The
149
149
call-graph should be defined as a predicate:
150
150
``` ql
151
+ /** Gets a viable target for the call `c`. */
151
152
DataFlowCallable viableCallable(DataFlowCall c)
152
153
```
153
154
Furthermore, each ` Node ` must be associated with exactly one callable and this
154
155
relation should be defined as:
155
156
``` ql
157
+ /** Gets the callable in which node `n` occurs. */
156
158
DataFlowCallable nodeGetEnclosingCallable(Node n)
157
159
```
158
160
159
161
In order to connect data-flow across calls, the 4 ` Node ` subclasses
160
162
` ArgumentNode ` , ` ParameterNode ` , ` ReturnNode ` , and ` OutNode ` are used.
161
- Flow into callables from arguments to parameters are matched up using an
162
- integer position, so these two predicates must be defined:
163
+ Flow into callables from arguments to parameters are matched up using
164
+ language-defined classes ` ParameterPosition ` and ` ArgumentPosition ` ,
165
+ so these three predicates must be defined:
163
166
``` ql
164
- ArgumentNode::argumentOf(DataFlowCall call, int pos)
165
- predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos)
167
+ /** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
168
+ predicate isParameterNode(ParameterNodeImpl p, DataFlowCallable c, ParameterPosition pos)
169
+
170
+ /** Holds if `arg` is an `ArgumentNode` of `c` with position `pos`. */
171
+ predicate isArgumentNode(ArgumentNode arg, DataFlowCall c, ArgumentPosition pos)
172
+
173
+ /** Holds if arguments at position `apos` match parameters at position `ppos`. */
174
+ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos)
166
175
```
167
- It is typical to use ` pos = -1 ` for an implicit ` this ` -parameter.
168
176
169
177
For most languages return-flow is simpler and merely consists of matching up a
170
178
` ReturnNode ` with the data-flow node corresponding to the value of the call,
@@ -174,8 +182,13 @@ calls and `OutNode`s:
174
182
``` ql
175
183
private newtype TReturnKind = TNormalReturnKind()
176
184
185
+ /** Gets the kind of this return node. */
177
186
ReturnKind ReturnNode::getKind() { any() }
178
187
188
+ /**
189
+ * Gets a node that can read the value returned from `call` with return kind
190
+ * `kind`.
191
+ */
179
192
OutNode getAnOutNode(DataFlowCall call, ReturnKind kind) {
180
193
result = call.getNode() and
181
194
kind = TNormalReturnKind()
0 commit comments