Skip to content

Commit 4009c01

Browse files
committed
Data flow: Cache readStep
1 parent 96aa182 commit 4009c01

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private module Cached {
339339
// read
340340
exists(Node mid |
341341
parameterValueFlowCand(p, mid, false) and
342-
readStep(mid, _, node) and
342+
read(mid, _, node) and
343343
read = true
344344
)
345345
or
@@ -658,7 +658,7 @@ private module Cached {
658658
Node node1, Content c, Node node2, DataFlowType contentType, DataFlowType containerType
659659
) {
660660
storeStep(node1, c, node2) and
661-
readStep(_, c, _) and
661+
read(_, c, _) and
662662
contentType = getNodeDataFlowType(node1) and
663663
containerType = getNodeDataFlowType(node2)
664664
or
@@ -668,12 +668,15 @@ private module Cached {
668668
|
669669
argumentValueFlowsThrough(n2, TReadStepTypesSome(containerType, c, contentType), n1)
670670
or
671-
readStep(n2, c, n1) and
671+
read(n2, c, n1) and
672672
contentType = getNodeDataFlowType(n1) and
673673
containerType = getNodeDataFlowType(n2)
674674
)
675675
}
676676

677+
cached
678+
predicate read(Node node1, Content c, Node node2) { readStep(node1, c, node2) }
679+
677680
/**
678681
* Holds if data can flow from `node1` to `node2` via a direct assignment to
679682
* `f`.
@@ -789,14 +792,14 @@ class CastingNode extends Node {
789792
// For reads, `x.f`, we want to check that the tracked type after the read (which
790793
// is obtained by popping the head of the access path stack) is compatible with
791794
// the type of `x.f`.
792-
readStep(_, _, this)
795+
read(_, _, this)
793796
}
794797
}
795798

796799
private predicate readStepWithTypes(
797800
Node n1, DataFlowType container, Content c, Node n2, DataFlowType content
798801
) {
799-
readStep(n1, c, n2) and
802+
read(n1, c, n2) and
800803
container = getNodeDataFlowType(n1) and
801804
content = getNodeDataFlowType(n2)
802805
}
@@ -1087,8 +1090,6 @@ DataFlowCallable resolveCall(DataFlowCall call, CallContext cc) {
10871090
result = viableCallableExt(call) and cc instanceof CallContextReturn
10881091
}
10891092

1090-
predicate read = readStep/3;
1091-
10921093
/** An optional Boolean value. */
10931094
class BooleanOption extends TBooleanOption {
10941095
string toString() {

0 commit comments

Comments
 (0)