Skip to content

Commit d5d0274

Browse files
committed
Java/SSA: Keep proper distinction between cached stages.
1 parent 4d04391 commit d5d0274

File tree

7 files changed

+18
-8
lines changed
  • cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal
  • csharp/ql/lib/semmle/code/csharp/dataflow/internal
  • javascript/ql/lib/semmle/javascript/dataflow/internal/sharedlib
  • java/ql/lib/semmle/code/java/dataflow/internal
  • ruby/ql/lib/codeql/ruby/dataflow/internal
  • rust/ql/lib/codeql/rust/dataflow/internal
  • shared/ssa/codeql/ssa

7 files changed

+18
-8
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ private module DataFlowIntegrationInput implements SsaImpl::DataFlowIntegrationI
10071007
}
10081008
}
10091009

1010-
predicate guardControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
1010+
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
10111011
guard.(IRGuards::IRGuardCondition).controls(bb, branch)
10121012
}
10131013

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
10621062
}
10631063

10641064
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
1065-
predicate guardControlsBlock(Guard guard, ControlFlow::BasicBlock bb, boolean branch) {
1065+
predicate guardDirectlyControlsBlock(Guard guard, ControlFlow::BasicBlock bb, boolean branch) {
10661066
exists(ConditionBlock conditionBlock, ControlFlow::SuccessorTypes::ConditionalSuccessor s |
10671067
guard.getAControlFlowNode() = conditionBlock.getLastNode() and
10681068
s.getValue() = branch and

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
680680
}
681681
}
682682

683+
/** Holds if the guard `guard` directly controls block `bb` upon evaluating to `branch`. */
684+
predicate guardDirectlyControlsBlock(Guard guard, BasicBlock bb, boolean branch) {
685+
guard.directlyControls(bb, branch)
686+
}
687+
683688
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
684689
predicate guardControlsBlock(Guard guard, BasicBlock bb, boolean branch) {
685690
guard.controls(bb, branch)

javascript/ql/lib/semmle/javascript/dataflow/internal/sharedlib/Ssa.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module SsaDataflowInput implements DataFlowIntegrationInputSig {
9797
}
9898

9999
pragma[inline]
100-
predicate guardControlsBlock(Guard guard, js::BasicBlock bb, boolean branch) {
100+
predicate guardDirectlyControlsBlock(Guard guard, js::BasicBlock bb, boolean branch) {
101101
exists(js::ConditionGuardNode g |
102102
g.getTest() = guard and
103103
g.dominates(bb) and

ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
503503
}
504504

505505
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
506-
predicate guardControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
506+
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
507507
Guards::guardControlsBlock(guard, bb, branch)
508508
}
509509
}

rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
377377
}
378378

379379
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
380-
predicate guardControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
380+
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
381381
exists(ConditionBasicBlock conditionBlock, ConditionalSuccessor s |
382382
guard = conditionBlock.getLastNode() and
383383
s.getValue() = branch and

shared/ssa/codeql/ssa/Ssa.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,13 @@ module Make<LocationSig Location, InputSig<Location> Input> {
14931493
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch);
14941494
}
14951495

1496+
/** Holds if `guard` directly controls block `bb` upon evaluating to `branch`. */
1497+
predicate guardDirectlyControlsBlock(Guard guard, BasicBlock bb, boolean branch);
1498+
14961499
/** Holds if `guard` controls block `bb` upon evaluating to `branch`. */
1497-
predicate guardControlsBlock(Guard guard, BasicBlock bb, boolean branch);
1500+
default predicate guardControlsBlock(Guard guard, BasicBlock bb, boolean branch) {
1501+
guardDirectlyControlsBlock(guard, bb, branch)
1502+
}
14981503

14991504
/**
15001505
* Holds if `WriteDefinition`s should be included as an intermediate node
@@ -1578,8 +1583,8 @@ module Make<LocationSig Location, InputSig<Location> Input> {
15781583
phi.getSourceVariable()) and
15791584
prev != input and
15801585
exists(DfInput::Guard g, boolean branch |
1581-
DfInput::guardControlsBlock(g, input, branch) and
1582-
not DfInput::guardControlsBlock(g, prev, branch)
1586+
DfInput::guardDirectlyControlsBlock(g, input, branch) and
1587+
not DfInput::guardDirectlyControlsBlock(g, prev, branch)
15831588
)
15841589
)
15851590
)

0 commit comments

Comments
 (0)