Skip to content

Commit 8bfeae7

Browse files
committed
Data flow: Cache simpleLocalFlowStep
1 parent 1a56f0b commit 8bfeae7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ private predicate fullBarrier(Node node, Configuration config) {
211211
* Holds if data can flow in one local step from `node1` to `node2`.
212212
*/
213213
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
214-
(
215-
simpleLocalFlowStep(node1, node2) or
216-
reverseStepThroughInputOutputAlias(node1, node2)
217-
) and
214+
simpleLocalFlowStepExt(node1, node2) and
218215
not outBarrier(node1, config) and
219216
not inBarrier(node2, config) and
220217
not fullBarrier(node1, config) and

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,9 @@ private module Cached {
689689
* are aliases. A typical example is a function returning `this`, implementing a fluent
690690
* interface.
691691
*/
692-
cached
693-
predicate reverseStepThroughInputOutputAlias(PostUpdateNode fromNode, PostUpdateNode toNode) {
692+
private predicate reverseStepThroughInputOutputAlias(
693+
PostUpdateNode fromNode, PostUpdateNode toNode
694+
) {
694695
exists(Node fromPre, Node toPre |
695696
fromPre = fromNode.getPreUpdateNode() and
696697
toPre = toNode.getPreUpdateNode()
@@ -707,6 +708,12 @@ private module Cached {
707708
)
708709
}
709710

711+
cached
712+
predicate simpleLocalFlowStepExt(Node node1, Node node2) {
713+
simpleLocalFlowStep(node1, node2) or
714+
reverseStepThroughInputOutputAlias(node1, node2)
715+
}
716+
710717
/**
711718
* Holds if the call context `call` either improves virtual dispatch in
712719
* `callable` or if it allows us to prune unreachable nodes in `callable`.

0 commit comments

Comments
 (0)