From c6ce13a0121bbf1cd53bb980aaf6b841e053fb11 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Tue, 19 May 2026 15:27:23 +0100 Subject: [PATCH] C++: Simplify recursion in 'PhiCycle::isCertain' and do not restrict the definition to be a 'PhiNode'. --- .../lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll index 4b21e83664c..9702a325d5e 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll @@ -1396,13 +1396,16 @@ private class PhiCycle extends PhiCycleEquivalence::EquivalenceClass { predicate hasPhiNode(PhiNode phi) { this.getAPhiNode() = phi } + pragma[nomagic] + Definition getAnInput() { + result = this.getAPhiNode().getAnInput() and not this.hasPhiNode(result) + } + string toString() { result = strictconcat(this.getAPhiNode().toString(), ", ") } predicate isCertain() { // A phi cycle is certain if all of the inputs into the phi cycle is certain. - forex(PhiNode phi | phi = this.getAPhiNode() | - forall(PhiNode inp | phi.getAnInput() = inp and not this.hasPhiNode(inp) | inp.isCertain()) - ) + forex(Definition inp | inp = this.getAnInput() | inp.isCertain()) } }