Skip to content

Commit de6e2c9

Browse files
committed
Data flow: Speedup subpaths predicate (take 2)
1 parent 6f9752e commit de6e2c9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,22 +4300,26 @@ private module Subpaths {
43004300
)
43014301
}
43024302

4303+
pragma[nomagic]
4304+
private predicate hasSuccessor(PathNode pred, PathNodeMid succ, NodeEx succNode) {
4305+
succ = pred.getASuccessor() and
4306+
succNode = succ.getNodeEx()
4307+
}
4308+
43034309
/**
43044310
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
43054311
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
43064312
* `ret -> out` is summarized as the edge `arg -> out`.
43074313
*/
43084314
predicate subpaths(PathNode arg, PathNodeImpl par, PathNodeImpl ret, PathNode out) {
43094315
exists(ParamNodeEx p, NodeEx o, FlowState sout, AccessPath apout, PathNodeMid out0 |
4310-
pragma[only_bind_into](arg).getASuccessor() = pragma[only_bind_into](par) and
4311-
pragma[only_bind_into](arg).getASuccessor() = out0 and
4316+
pragma[only_bind_into](arg).getASuccessor() = pragma[only_bind_into](out0) and
43124317
subpaths03(pragma[only_bind_into](arg), p, localStepToHidden*(ret), o, sout, apout) and
4318+
hasSuccessor(pragma[only_bind_into](arg), par, p) and
43134319
not ret.isHidden() and
4314-
par.getNodeEx() = p and
4315-
out0.getNodeEx() = o and
4316-
out0.getState() = sout and
4317-
out0.getAp() = apout and
4318-
(out = out0 or out = out0.projectToSink())
4320+
pathNode(out0, o, sout, _, _, apout, _, _)
4321+
|
4322+
out = out0 or out = out0.projectToSink()
43194323
)
43204324
}
43214325

0 commit comments

Comments
 (0)