Skip to content

Commit 4cc2771

Browse files
committed
C++: Speed up the big step relation by specializing the 'isUnrachableInCall' predicate.
1 parent bb521d7 commit 4cc2771

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ module Impl<FullStateConfigSig Config> {
254254
not fullBarrier(node2)
255255
}
256256

257+
pragma[nomagic]
258+
private predicate isUnreachableInCall1(NodeEx n, LocalCallContextSpecificCall cc) {
259+
isUnreachableInCallCached(n.asNode(), cc.getCall())
260+
}
261+
257262
/**
258263
* Holds if data can flow in one local step from `node1` to `node2`.
259264
*/
@@ -2108,7 +2113,7 @@ module Impl<FullStateConfigSig Config> {
21082113
NodeEx node1, FlowState state, NodeEx node2, boolean preservesValue, DataFlowType t,
21092114
LocalCallContext cc
21102115
) {
2111-
not isUnreachableInCallCached(node2.asNode(), cc.(LocalCallContextSpecificCall).getCall()) and
2116+
not isUnreachableInCall1(node2, cc) and
21122117
(
21132118
localFlowEntry(node1, pragma[only_bind_into](state)) and
21142119
(
@@ -2123,7 +2128,7 @@ module Impl<FullStateConfigSig Config> {
21232128
) and
21242129
node1 != node2 and
21252130
cc.relevantFor(node1.getEnclosingCallable()) and
2126-
not isUnreachableInCallCached(node1.asNode(), cc.(LocalCallContextSpecificCall).getCall())
2131+
not isUnreachableInCall1(node1, cc)
21272132
or
21282133
exists(NodeEx mid |
21292134
localFlowStepPlus(node1, pragma[only_bind_into](state), mid, preservesValue, t, cc) and
@@ -2160,10 +2165,8 @@ module Impl<FullStateConfigSig Config> {
21602165
preservesValue = false and
21612166
t = node2.getDataFlowType() and
21622167
callContext.relevantFor(node1.getEnclosingCallable()) and
2163-
not exists(DataFlowCall call | call = callContext.(LocalCallContextSpecificCall).getCall() |
2164-
isUnreachableInCallCached(node1.asNode(), call) or
2165-
isUnreachableInCallCached(node2.asNode(), call)
2166-
)
2168+
not isUnreachableInCall1(node1, callContext) and
2169+
not isUnreachableInCall1(node2, callContext)
21672170
}
21682171
}
21692172

0 commit comments

Comments
 (0)