Skip to content

Commit d880379

Browse files
committed
Shared: Force join order in VariableCapture
1 parent 7c82cde commit d880379

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
@@ -483,6 +483,7 @@ module Flow<
483483
}
484484

485485
/** Gets the enclosing callable of `ce`. */
486+
pragma[nomagic]
486487
private Callable closureExprGetEnclosingCallable(ClosureExpr ce) {
487488
exists(BasicBlock bb | ce.hasCfgNode(bb, _) and result = bb.getEnclosingCallable())
488489
}
@@ -496,6 +497,13 @@ module Flow<
496497
)
497498
}
498499

500+
/** Holds if `outer` contains or equals `inner` */
501+
bindingset[outer, inner]
502+
pragma[inline_late]
503+
private predicate isEnclosingCallable(Callable outer, Callable inner) {
504+
outer = callableGetEnclosingCallable*(inner)
505+
}
506+
499507
/**
500508
* Gets a callable that contains `ce`, or a reference to `ce` into which `ce` could be inlined without
501509
* bringing any variables out of scope.
@@ -512,7 +520,7 @@ module Flow<
512520
expr.hasCfgNode(bb, _) and
513521
result = bb.getEnclosingCallable() and
514522
// The reference to `ce` is allowed to occur in a more deeply nested context
515-
closureExprGetEnclosingCallable(ce) = callableGetEnclosingCallable*(result)
523+
isEnclosingCallable(closureExprGetEnclosingCallable(ce), result)
516524
)
517525
}
518526

0 commit comments

Comments
 (0)