@@ -155,7 +155,7 @@ private predicate variableReadActual(BasicBlock bb, int i, Variable v) {
155155 */
156156pragma [ noinline]
157157private predicate hasCapturedWrite ( Variable v , Cfg:: CfgScope scope ) {
158- any ( VariableWriteAccess write | write .getVariable ( ) = v and scope = write .getEnclosingCallable * ( ) )
158+ any ( VariableWriteAccess write | write .getVariable ( ) = v and scope = write .getEnclosingCallable + ( ) )
159159 .isCapture ( )
160160}
161161
@@ -262,7 +262,7 @@ private predicate readsCapturedVariable(BasicBlock bb, Variable v) {
262262 */
263263pragma [ noinline]
264264private predicate hasCapturedRead ( Variable v , Cfg:: CfgScope scope ) {
265- any ( VariableReadAccess read | read .getVariable ( ) = v and scope = read .getEnclosingCallable * ( ) )
265+ any ( VariableReadAccess read | read .getVariable ( ) = v and scope = read .getEnclosingCallable + ( ) )
266266 .isCapture ( )
267267}
268268
@@ -290,6 +290,19 @@ private predicate capturedCallRead(CallExprBase call, BasicBlock bb, int i, Vari
290290 )
291291}
292292
293+ /**
294+ * Holds if the call `call` at index `i` in basic block `bb` may reach a callable
295+ * that writes captured variable `v`.
296+ */
297+ predicate capturedCallWrite ( CallExprBase call , BasicBlock bb , int i , Variable v ) {
298+ call = bb .getNode ( i ) .getAstNode ( ) and
299+ exists ( Cfg:: CfgScope scope |
300+ hasVariableReadWithCapturedWrite ( bb , any ( int j | j > i ) , v , scope )
301+ or
302+ hasVariableReadWithCapturedWrite ( bb .getASuccessor + ( ) , _, v , scope )
303+ )
304+ }
305+
293306/**
294307 * Holds if a pseudo read of captured variable `v` should be inserted
295308 * at index `i` in exit block `bb`.
@@ -312,20 +325,6 @@ private module Cached {
312325 i = - 1
313326 }
314327
315- /**
316- * Holds if the call `call` at index `i` in basic block `bb` may reach a callable
317- * that writes captured variable `v`.
318- */
319- cached
320- predicate capturedCallWrite ( CallExprBase call , BasicBlock bb , int i , Variable v ) {
321- call = bb .getNode ( i ) .getAstNode ( ) and
322- exists ( Cfg:: CfgScope scope |
323- hasVariableReadWithCapturedWrite ( bb , any ( int j | j > i ) , v , scope )
324- or
325- hasVariableReadWithCapturedWrite ( bb .getASuccessor + ( ) , _, v , scope )
326- )
327- }
328-
329328 /**
330329 * Holds if `v` is written at index `i` in basic block `bb`, and the corresponding
331330 * AST write access is `write`.
0 commit comments