From f5113b1932d2dc1ea4e55fb3115cb56e33c6796b Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Tue, 19 May 2026 15:39:32 +0100 Subject: [PATCH] C++: Fix internal SCC edges and accept test changes. --- .../semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll | 10 +++------- cpp/ql/test/library-tests/dataflow/certain/test.cpp | 4 ++-- 2 files changed, 5 insertions(+), 9 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 9702a325d5e..432261dfe27 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 @@ -1379,15 +1379,11 @@ class PhiNode extends Definition instanceof SsaImpl::PhiNode { private PhiNode getAnInput(PhiNode phi) { result = phi.getAnInput() } -private predicate definitionCycle(PhiNode phi) { getAnInput+(phi) = phi } - -private predicate hasAnInput(PhiNode phi1, PhiNode phi2) { - definitionCycle(phi1) and - definitionCycle(phi2) and - getAnInput(phi1) = phi2 +private predicate sccEdge(PhiNode phi1, PhiNode phi2) { + getAnInput(phi1) = phi2 and getAnInput+(phi2) = phi1 } -private module PhiCycleEquivalence = QlBuiltins::EquivalenceRelation; +private module PhiCycleEquivalence = QlBuiltins::EquivalenceRelation; private PhiCycle getCycle(PhiNode phi) { result.getAPhiNode() = phi } diff --git a/cpp/ql/test/library-tests/dataflow/certain/test.cpp b/cpp/ql/test/library-tests/dataflow/certain/test.cpp index eece48c2ea3..029c329a36d 100644 --- a/cpp/ql/test/library-tests/dataflow/certain/test.cpp +++ b/cpp/ql/test/library-tests/dataflow/certain/test.cpp @@ -67,11 +67,11 @@ void test(int x, bool b1, bool b2) { // $ certain="SSA def(&x)" certain="SSA def int* p = &x; // $ certain="SSA def(&p)" certain="SSA def(p)" certain="SSA def(*p)" int i = 0; // $ certain="SSA def(&i)" certain="SSA def(i)" int j = 0; // $ certain="SSA def(&j)" certain="SSA def(j)" - while (i < 10) { // $ certain="SSA phi(i)" uncertain="SSA phi(*p)" + while (i < 10) { // $ certain="SSA phi(i)" certain="SSA phi(*p)" if (b1) { *p = 0; // $ certain="SSA def(*p)" } - ++i; // $ certain="SSA def(i)" uncertain="SSA phi(*p)" + ++i; // $ certain="SSA def(i)" certain="SSA phi(*p)" } while (j < 10) { // $ uncertain="SSA phi(*p)" certain="SSA phi(j)" if (b2) {