Skip to content

Commit 194afbb

Browse files
committed
Java: Simplify SSA for variable capture.
1 parent 35f50ba commit 194afbb

File tree

1 file changed

+1
-16
lines changed
  • java/ql/lib/semmle/code/java/dataflow/internal

1 file changed

+1
-16
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -490,26 +490,11 @@ private module Cached {
490490
)
491491
}
492492

493-
pragma[nomagic]
494-
private predicate captureDefReaches(Definition def, SsaInput::BasicBlock bb2, int i2) {
495-
variableCapture(def.getSourceVariable(), _, _, _) and
496-
exists(SsaInput::BasicBlock bb1, int i1 |
497-
Impl::adjacentDefRead(def, bb1, i1, bb2, i2) and
498-
def.definesAt(_, bb1, i1)
499-
)
500-
or
501-
exists(SsaInput::BasicBlock bb3, int i3 |
502-
captureDefReaches(def, bb3, i3) and
503-
SsaInput::variableRead(bb3, i3, _, _) and
504-
Impl::adjacentDefRead(def, bb3, i3, bb2, i2)
505-
)
506-
}
507-
508493
/** Holds if `init` is a closure variable that captures the value of `capturedvar`. */
509494
cached
510495
predicate captures(SsaImplicitInit init, SsaVariable capturedvar) {
511496
exists(BasicBlock bb, int i |
512-
captureDefReaches(capturedvar, bb, i) and
497+
Impl::ssaDefReachesRead(_, capturedvar, bb, i) and
513498
variableCapture(capturedvar.getSourceVariable(), init.getSourceVariable(), bb, i)
514499
)
515500
}

0 commit comments

Comments
 (0)