Skip to content

Commit 23113c4

Browse files
committed
Data flow: Cache isUnreachableInCall
1 parent 1bf0e01 commit 23113c4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ private module LocalFlowBigStep {
13181318
Node node1, Node node2, boolean preservesValue, DataFlowType t, Configuration config,
13191319
LocalCallContext cc
13201320
) {
1321-
not isUnreachableInCall(node2, cc.(LocalCallContextSpecificCall).getCall()) and
1321+
not isUnreachableInCallCached(node2, cc.(LocalCallContextSpecificCall).getCall()) and
13221322
(
13231323
localFlowEntry(node1, pragma[only_bind_into](config)) and
13241324
(
@@ -1332,7 +1332,7 @@ private module LocalFlowBigStep {
13321332
) and
13331333
node1 != node2 and
13341334
cc.relevantFor(getNodeEnclosingCallable(node1)) and
1335-
not isUnreachableInCall(node1, cc.(LocalCallContextSpecificCall).getCall()) and
1335+
not isUnreachableInCallCached(node1, cc.(LocalCallContextSpecificCall).getCall()) and
13361336
Stage2::revFlow(node2, pragma[only_bind_into](config))
13371337
or
13381338
exists(Node mid |
@@ -3782,7 +3782,7 @@ private module FlowExploration {
37823782
PartialPathNodeFwd mid, Node node, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
37833783
PartialAccessPath ap, Configuration config
37843784
) {
3785-
not isUnreachableInCall(node, cc.(CallContextSpecificCall).getCall()) and
3785+
not isUnreachableInCallCached(node, cc.(CallContextSpecificCall).getCall()) and
37863786
(
37873787
localFlowStep(mid.getNode(), node, config) and
37883788
cc = mid.getCallContext() and

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ private module Cached {
259259
cached
260260
predicate clearsContentCached(Node n, Content c) { clearsContent(n, c) }
261261

262+
cached
263+
predicate isUnreachableInCallCached(Node n, DataFlowCall call) { isUnreachableInCall(n, call) }
264+
262265
/**
263266
* Gets a viable target for the lambda call `call`.
264267
*
@@ -731,7 +734,7 @@ private module Cached {
731734
predicate recordDataFlowCallSite(DataFlowCall call, DataFlowCallable callable) {
732735
reducedViableImplInCallContext(_, callable, call)
733736
or
734-
exists(Node n | getNodeEnclosingCallable(n) = callable | isUnreachableInCall(n, call))
737+
exists(Node n | getNodeEnclosingCallable(n) = callable | isUnreachableInCallCached(n, call))
735738
}
736739

737740
cached
@@ -753,7 +756,7 @@ private module Cached {
753756
cached
754757
newtype TLocalFlowCallContext =
755758
TAnyLocalCall() or
756-
TSpecificLocalCall(DataFlowCall call) { isUnreachableInCall(_, call) }
759+
TSpecificLocalCall(DataFlowCall call) { isUnreachableInCallCached(_, call) }
757760

758761
cached
759762
newtype TReturnKindExt =
@@ -926,7 +929,7 @@ class LocalCallContextSpecificCall extends LocalCallContext, TSpecificLocalCall
926929
}
927930

928931
private predicate relevantLocalCCtx(DataFlowCall call, DataFlowCallable callable) {
929-
exists(Node n | getNodeEnclosingCallable(n) = callable and isUnreachableInCall(n, call))
932+
exists(Node n | getNodeEnclosingCallable(n) = callable and isUnreachableInCallCached(n, call))
930933
}
931934

932935
/**

0 commit comments

Comments
 (0)