Skip to content

Commit c6ce13a

Browse files
committed
C++: Simplify recursion in 'PhiCycle::isCertain' and do not restrict the definition to be a 'PhiNode'.
1 parent d93de54 commit c6ce13a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,13 +1396,16 @@ private class PhiCycle extends PhiCycleEquivalence::EquivalenceClass {
13961396

13971397
predicate hasPhiNode(PhiNode phi) { this.getAPhiNode() = phi }
13981398

1399+
pragma[nomagic]
1400+
Definition getAnInput() {
1401+
result = this.getAPhiNode().getAnInput() and not this.hasPhiNode(result)
1402+
}
1403+
13991404
string toString() { result = strictconcat(this.getAPhiNode().toString(), ", ") }
14001405

14011406
predicate isCertain() {
14021407
// A phi cycle is certain if all of the inputs into the phi cycle is certain.
1403-
forex(PhiNode phi | phi = this.getAPhiNode() |
1404-
forall(PhiNode inp | phi.getAnInput() = inp and not this.hasPhiNode(inp) | inp.isCertain())
1405-
)
1408+
forex(Definition inp | inp = this.getAnInput() | inp.isCertain())
14061409
}
14071410
}
14081411

0 commit comments

Comments
 (0)