Skip to content

Commit 31374b4

Browse files
committed
Data flow: Update documentation
1 parent e410244 commit 31374b4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

docs/ql-libraries/dataflow/dataflow.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,31 @@ methods, constructors, lambdas, etc.). It can also be useful to represent
148148
`DataFlowCall` as an IPA type if implicit calls need to be modelled. The
149149
call-graph should be defined as a predicate:
150150
```ql
151+
/** Gets a viable target for the call `c`. */
151152
DataFlowCallable viableCallable(DataFlowCall c)
152153
```
153154
Furthermore, each `Node` must be associated with exactly one callable and this
154155
relation should be defined as:
155156
```ql
157+
/** Gets the callable in which node `n` occurs. */
156158
DataFlowCallable nodeGetEnclosingCallable(Node n)
157159
```
158160

159161
In order to connect data-flow across calls, the 4 `Node` subclasses
160162
`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:
163166
```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)
166175
```
167-
It is typical to use `pos = -1` for an implicit `this`-parameter.
168176

169177
For most languages return-flow is simpler and merely consists of matching up a
170178
`ReturnNode` with the data-flow node corresponding to the value of the call,
@@ -174,8 +182,13 @@ calls and `OutNode`s:
174182
```ql
175183
private newtype TReturnKind = TNormalReturnKind()
176184
185+
/** Gets the kind of this return node. */
177186
ReturnKind ReturnNode::getKind() { any() }
178187
188+
/**
189+
* Gets a node that can read the value returned from `call` with return kind
190+
* `kind`.
191+
*/
179192
OutNode getAnOutNode(DataFlowCall call, ReturnKind kind) {
180193
result = call.getNode() and
181194
kind = TNormalReturnKind()

0 commit comments

Comments
 (0)