Skip to content

Commit 753f0d4

Browse files
committed
Shared: Force join order in VariableCapture
1 parent d0cd3c5 commit 753f0d4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎shared/dataflow/codeql/dataflow/VariableCapture.qll‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ module Flow<
481481
}
482482

483483
/** Gets the enclosing callable of `ce`. */
484+
pragma[nomagic]
484485
private Callable closureExprGetEnclosingCallable(ClosureExpr ce) {
485486
exists(BasicBlock bb | ce.hasCfgNode(bb, _) and result = bb.getEnclosingCallable())
486487
}
@@ -494,6 +495,13 @@ module Flow<
494495
)
495496
}
496497

498+
/** Holds if `outer` contains or equals `inner` */
499+
bindingset[outer, inner]
500+
pragma[inline_late]
501+
private predicate isEnclosingCallable(Callable outer, Callable inner) {
502+
outer = callableGetEnclosingCallable*(inner)
503+
}
504+
497505
/**
498506
* Gets a callable that contains `ce`, or a reference to `ce` into which `ce` could be inlined without
499507
* bringing any variables out of scope.
@@ -510,7 +518,7 @@ module Flow<
510518
expr.hasCfgNode(bb, _) and
511519
result = bb.getEnclosingCallable() and
512520
// The reference to `ce` is allowed to occur in a more deeply nested context
513-
closureExprGetEnclosingCallable(ce) = callableGetEnclosingCallable*(result)
521+
isEnclosingCallable(closureExprGetEnclosingCallable(ce), result)
514522
)
515523
}
516524

0 commit comments

Comments
 (0)