@@ -156,7 +156,7 @@ private predicate variableReadActual(BasicBlock bb, int i, Variable v) {
156156 */
157157pragma [ noinline]
158158private predicate hasCapturedWrite ( Variable v , Cfg:: CfgScope scope ) {
159- any ( VariableWriteAccess write | write .getVariable ( ) = v and scope = getEnclosingCfgScope + ( write ) )
159+ any ( VariableWriteAccess write | write .getVariable ( ) = v and scope = write . getEnclosingCfgScope + ( ) )
160160 .isCapture ( )
161161}
162162
@@ -168,7 +168,7 @@ pragma[noinline]
168168private predicate variableReadActualInOuterScope (
169169 BasicBlock bb , int i , Variable v , Cfg:: CfgScope scope
170170) {
171- variableReadActual ( bb , i , v ) and bb .getScope ( ) = getEnclosingCfgScope ( scope )
171+ variableReadActual ( bb , i , v ) and bb .getScope ( ) = scope . getEnclosingCfgScope ( )
172172}
173173
174174pragma [ noinline]
@@ -263,7 +263,7 @@ private predicate readsCapturedVariable(BasicBlock bb, Variable v) {
263263 */
264264pragma [ noinline]
265265private predicate hasCapturedRead ( Variable v , Cfg:: CfgScope scope ) {
266- any ( VariableReadAccess read | read .getVariable ( ) = v and scope = getEnclosingCfgScope + ( read ) )
266+ any ( VariableReadAccess read | read .getVariable ( ) = v and scope = read . getEnclosingCfgScope + ( ) )
267267 .isCapture ( )
268268}
269269
@@ -273,15 +273,18 @@ private predicate hasCapturedRead(Variable v, Cfg::CfgScope scope) {
273273 */
274274pragma [ noinline]
275275private predicate variableWriteInOuterScope ( BasicBlock bb , int i , Variable v , Cfg:: CfgScope scope ) {
276- SsaInput:: variableWrite ( bb , i , v , _) and getEnclosingCfgScope ( scope ) = bb .getScope ( )
276+ SsaInput:: variableWrite ( bb , i , v , _) and scope . getEnclosingCfgScope ( ) = bb .getScope ( )
277277}
278278
279+ /** Holds if evaluating `e` jumps to the evaluation of a different CFG scope. */
280+ private predicate isControlFlowJump ( Expr e ) { e instanceof CallExprBase or e instanceof AwaitExpr }
281+
279282/**
280283 * Holds if the call `call` at index `i` in basic block `bb` may reach
281284 * a callable that reads captured variable `v`.
282285 */
283286private predicate capturedCallRead ( Expr call , BasicBlock bb , int i , Variable v ) {
284- Cfg :: isControlFlowJump ( call ) and
287+ isControlFlowJump ( call ) and
285288 exists ( Cfg:: CfgScope scope |
286289 hasCapturedRead ( v , scope ) and
287290 (
@@ -297,7 +300,7 @@ private predicate capturedCallRead(Expr call, BasicBlock bb, int i, Variable v)
297300 * that writes captured variable `v`.
298301 */
299302predicate capturedCallWrite ( Expr call , BasicBlock bb , int i , Variable v ) {
300- Cfg :: isControlFlowJump ( call ) and
303+ isControlFlowJump ( call ) and
301304 call = bb .getNode ( i ) .getAstNode ( ) and
302305 exists ( Cfg:: CfgScope scope |
303306 hasVariableReadWithCapturedWrite ( bb , any ( int j | j > i ) , v , scope )
0 commit comments