Skip to content

Commit 26d14ab

Browse files
committed
Python: Use nodeFrom/nodeTo instead of pred/succ
1 parent ec64606 commit 26d14ab

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

python/ql/src/experimental/dataflow/TypeTracker.qll

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,48 +46,48 @@ class StepSummary extends TStepSummary {
4646

4747
module StepSummary {
4848
cached
49-
predicate step(Node pred, Node succ, StepSummary summary) {
50-
exists(Node mid | EssaFlow::essaFlowStep*(pred, mid) and smallstep(mid, succ, summary))
49+
predicate step(Node nodeFrom, Node nodeTo, StepSummary summary) {
50+
exists(Node mid | EssaFlow::essaFlowStep*(nodeFrom, mid) and smallstep(mid, nodeTo, summary))
5151
}
5252

53-
predicate smallstep(Node pred, Node succ, StepSummary summary) {
54-
EssaFlow::essaFlowStep(pred, succ) and
53+
predicate smallstep(Node nodeFrom, Node nodeTo, StepSummary summary) {
54+
EssaFlow::essaFlowStep(nodeFrom, nodeTo) and
5555
summary = LevelStep()
5656
or
57-
callStep(pred, succ) and summary = CallStep()
57+
callStep(nodeFrom, nodeTo) and summary = CallStep()
5858
or
59-
returnStep(pred, succ) and
59+
returnStep(nodeFrom, nodeTo) and
6060
summary = ReturnStep()
6161
or
6262
exists(string attr |
63-
basicStoreStep(pred, succ, attr) and
63+
basicStoreStep(nodeFrom, nodeTo, attr) and
6464
summary = StoreStep(attr)
6565
or
66-
basicLoadStep(pred, succ, attr) and summary = LoadStep(attr)
66+
basicLoadStep(nodeFrom, nodeTo, attr) and summary = LoadStep(attr)
6767
)
6868
}
6969
}
7070

71-
/** Holds if `pred` steps to `succ` by being passed as a parameter in a call. */
72-
predicate callStep(ArgumentNode pred, ParameterNode succ) {
71+
/** Holds if `nodeFrom` steps to `nodeTo` by being passed as a parameter in a call. */
72+
predicate callStep(ArgumentNode nodeFrom, ParameterNode nodeTo) {
7373
// TODO: Support special methods?
7474
exists(DataFlowCall call, int i |
75-
pred.argumentOf(call, i) and succ.isParameterOf(call.getCallable(), i)
75+
nodeFrom.argumentOf(call, i) and nodeTo.isParameterOf(call.getCallable(), i)
7676
)
7777
}
7878

79-
/** Holds if `pred` steps to `succ` by being returned from a call. */
80-
predicate returnStep(ReturnNode pred, Node succ) {
79+
/** Holds if `nodeFrom` steps to `nodeTo` by being returned from a call. */
80+
predicate returnStep(ReturnNode nodeFrom, Node nodeTo) {
8181
exists(DataFlowCall call |
82-
pred.getEnclosingCallable() = call.getCallable() and succ.asCfgNode() = call
82+
nodeFrom.getEnclosingCallable() = call.getCallable() and nodeTo.asCfgNode() = call
8383
)
8484
}
8585

8686
/**
87-
* Holds if `pred` is being written to the `attr` attribute of the object in `succ`.
87+
* Holds if `nodeFrom` is being written to the `attr` attribute of the object in `nodeTo`.
8888
*
89-
* Note that the choice of `succ` does not have to make sense "chronologically".
90-
* All we care about is whether the `attr` attribute of `succ` can have a specific type,
89+
* Note that the choice of `nodeTo` does not have to make sense "chronologically".
90+
* All we care about is whether the `attr` attribute of `nodeTo` can have a specific type,
9191
* and the assumption is that if a specific type appears here, then any access of that
9292
* particular attribute can yield something of that particular type.
9393
*
@@ -104,24 +104,24 @@ predicate returnStep(ReturnNode pred, Node succ) {
104104
* z = x.attr
105105
* ```
106106
* for the attribute write `x.attr = y`, we will have `attr` being the literal string `"attr"`,
107-
* `pred` will be `y`, and `succ` will be the object `Foo()` created on the first line of the
107+
* `nodeFrom` will be `y`, and `nodeTo` will be the object `Foo()` created on the first line of the
108108
* function. This means we will track the fact that `x.attr` can have the type of `y` into the
109109
* assignment to `z` inside `bar`, even though this attribute write happens _after_ `bar` is called.
110110
*/
111-
predicate basicStoreStep(Node pred, Node succ, string attr) {
111+
predicate basicStoreStep(Node nodeFrom, Node nodeTo, string attr) {
112112
exists(AttributeAssignment a, Node var |
113113
a.getName() = attr and
114-
EssaFlow::essaFlowStep*(succ, var) and
114+
EssaFlow::essaFlowStep*(nodeTo, var) and
115115
var.asVar() = a.getInput() and
116-
pred.asCfgNode() = a.getValue()
116+
nodeFrom.asCfgNode() = a.getValue()
117117
)
118118
}
119119

120120
/**
121-
* Holds if `succ` is the result of accessing the `attr` attribute of `pred`.
121+
* Holds if `nodeTo` is the result of accessing the `attr` attribute of `nodeFrom`.
122122
*/
123-
predicate basicLoadStep(Node pred, Node succ, string attr) {
124-
exists(AttrNode s | succ.asCfgNode() = s and s.getObject(attr) = pred.asCfgNode())
123+
predicate basicLoadStep(Node nodeFrom, Node nodeTo, string attr) {
124+
exists(AttrNode s | nodeTo.asCfgNode() = s and s.getObject(attr) = nodeFrom.asCfgNode())
125125
}
126126

127127
/**
@@ -235,19 +235,19 @@ class TypeTracker extends TTypeTracker {
235235

236236
/**
237237
* Gets the summary that corresponds to having taken a forwards
238-
* heap and/or inter-procedural step from `pred` to `succ`.
238+
* heap and/or inter-procedural step from `nodeFrom` to `nodeTo`.
239239
*/
240240
pragma[inline]
241-
TypeTracker step(Node pred, Node succ) {
241+
TypeTracker step(Node nodeFrom, Node nodeTo) {
242242
exists(StepSummary summary |
243-
StepSummary::step(pred, succ, summary) and
243+
StepSummary::step(nodeFrom, nodeTo, summary) and
244244
result = this.append(summary)
245245
)
246246
}
247247

248248
/**
249249
* Gets the summary that corresponds to having taken a forwards
250-
* local, heap and/or inter-procedural step from `pred` to `succ`.
250+
* local, heap and/or inter-procedural step from `nodeFrom` to `nodeTo`.
251251
*
252252
* Unlike `TypeTracker::step`, this predicate exposes all edges
253253
* in the flow graph, and not just the edges between `Node`s.
@@ -270,13 +270,13 @@ class TypeTracker extends TTypeTracker {
270270
* ```
271271
*/
272272
pragma[inline]
273-
TypeTracker smallstep(Node pred, Node succ) {
273+
TypeTracker smallstep(Node nodeFrom, Node nodeTo) {
274274
exists(StepSummary summary |
275-
StepSummary::smallstep(pred, succ, summary) and
275+
StepSummary::smallstep(nodeFrom, nodeTo, summary) and
276276
result = this.append(summary)
277277
)
278278
or
279-
EssaFlow::essaFlowStep(pred, succ) and
279+
EssaFlow::essaFlowStep(nodeFrom, nodeTo) and
280280
result = this
281281
}
282282
}

0 commit comments

Comments
 (0)