Skip to content

Commit 3ef3e6e

Browse files
authored
Merge pull request #4319 from hvitved/python-java-block-precedes-var
Java/Python: Reduce size of `blockPrecedesVar`
2 parents d4d4c0f + 71da904 commit 3ef3e6e

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/SSA.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,9 @@ module Ssa {
706706

707707
/**
708708
* Holds if `def` is accessed in basic block `bb1` (either a read or a write),
709-
* `bb2` is a transitive successor of `bb1`, and `def` is *maybe* read in `bb2`
710-
* or one of its transitive successors, but not in any block on the path between
711-
* `bb1` and `bb2`.
709+
* `bb2` is a transitive successor of `bb1`, `def` is live at the end of `bb1`,
710+
* and the underlying variable for `def` is neither read nor written in any block
711+
* on the path between `bb1` and `bb2`.
712712
*/
713713
private predicate varBlockReaches(TrackedDefinition def, BasicBlock bb1, BasicBlock bb2) {
714714
varOccursInBlock(def, bb1, _) and

java/ql/src/semmle/code/java/dataflow/SSA.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ private module SsaImpl {
770770

771771
/** Holds if `v` occurs in `b` or one of `b`'s transitive successors. */
772772
private predicate blockPrecedesVar(TrackedVar v, BasicBlock b) {
773-
varOccursInBlock(v, b.getABBSuccessor*())
773+
varOccursInBlock(v, b)
774+
or
775+
ssaDefReachesEndOfBlock(v, _, b)
774776
}
775777

776778
/**

java/ql/src/semmle/code/java/dataflow/internal/BaseSSA.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ private module SsaImpl {
321321

322322
/** Holds if `v` occurs in `b` or one of `b`'s transitive successors. */
323323
private predicate blockPrecedesVar(BaseSsaSourceVariable v, BasicBlock b) {
324-
varOccursInBlock(v, b.getABBSuccessor*())
324+
varOccursInBlock(v, b)
325+
or
326+
ssaDefReachesEndOfBlock(v, _, b)
325327
}
326328

327329
/**

python/ql/src/semmle/python/essa/SsaCompute.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ private module SsaComputeImpl {
382382

383383
/** Holds if `v` occurs in `b` or one of `b`'s transitive successors. */
384384
private predicate blockPrecedesVar(SsaSourceVariable v, BasicBlock b) {
385-
varOccursInBlock(v, b.getASuccessor*())
385+
varOccursInBlock(v, b)
386+
or
387+
SsaDefinitionsImpl::reachesEndOfBlock(v, _, _, b)
386388
}
387389

388390
/**

0 commit comments

Comments
 (0)