Skip to content

Commit bbdedf5

Browse files
committed
Ruby: Eliminate bad isLocalSourceNode antijoin
Gets rid of ``` Tuple counts for DataFlowPrivate::Cached::isLocalSourceNode#462ff392#f#antijoin_rhs@dd2f927s: 20905019 ~3% {2} r1 = JOIN DataFlowPrivate::Cached::TExprNode#462ff392#ff_1#higher_order_body WITH boundedFastTC(DataFlowPrivate::Cached::localFlowStepTypeTracker#462ff392#ff_10#higher_order_body,DataFlowPrivate::Cached::TExprNode#462ff392#ff_1#higher_order_body) ON FIRST 1 OUTPUT Rhs.1, Lhs.0 10420128 ~1496% {1} r2 = JOIN r1 WITH DataFlowPrivate::Cached::TExprNode#462ff392#ff_1#higher_order_body ON FIRST 1 OUTPUT Lhs.1 480918 ~8% {1} r3 = JOIN r1 WITH DataFlowPrivate::Cached::entrySsaDefinition#462ff392#f ON FIRST 1 OUTPUT Lhs.1 10901046 ~1218% {1} r4 = r2 UNION r3 return r4 ```
1 parent 7971b54 commit bbdedf5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,18 +298,28 @@ private module Cached {
298298
)
299299
}
300300

301+
pragma[nomagic]
302+
private predicate reachedFromExprOrEntrySsaDef(Node n) {
303+
localFlowStepTypeTracker(any(Node n0 |
304+
n0 instanceof ExprNode
305+
or
306+
entrySsaDefinition(n0)
307+
), n)
308+
or
309+
exists(Node mid |
310+
reachedFromExprOrEntrySsaDef(mid) and
311+
localFlowStepTypeTracker(mid, n)
312+
)
313+
}
314+
301315
cached
302316
predicate isLocalSourceNode(Node n) {
303317
n instanceof ParameterNode
304318
or
305319
n instanceof PostUpdateNodes::ExprPostUpdateNode
306320
or
307321
// Nodes that can't be reached from another entry definition or expression.
308-
not localFlowStepTypeTracker+(any(Node n0 |
309-
n0 instanceof ExprNode
310-
or
311-
entrySsaDefinition(n0)
312-
), n)
322+
not reachedFromExprOrEntrySsaDef(n)
313323
or
314324
// Ensure all entry SSA definitions are local sources -- for parameters, this
315325
// is needed by type tracking. Note that when the parameter has a default value,

0 commit comments

Comments
 (0)