Skip to content

Commit f5113b1

Browse files
committed
C++: Fix internal SCC edges and accept test changes.
1 parent f77d426 commit f5113b1

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

  • cpp/ql

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,15 +1379,11 @@ class PhiNode extends Definition instanceof SsaImpl::PhiNode {
13791379

13801380
private PhiNode getAnInput(PhiNode phi) { result = phi.getAnInput() }
13811381

1382-
private predicate definitionCycle(PhiNode phi) { getAnInput+(phi) = phi }
1383-
1384-
private predicate hasAnInput(PhiNode phi1, PhiNode phi2) {
1385-
definitionCycle(phi1) and
1386-
definitionCycle(phi2) and
1387-
getAnInput(phi1) = phi2
1382+
private predicate sccEdge(PhiNode phi1, PhiNode phi2) {
1383+
getAnInput(phi1) = phi2 and getAnInput+(phi2) = phi1
13881384
}
13891385

1390-
private module PhiCycleEquivalence = QlBuiltins::EquivalenceRelation<PhiNode, hasAnInput/2>;
1386+
private module PhiCycleEquivalence = QlBuiltins::EquivalenceRelation<PhiNode, sccEdge/2>;
13911387

13921388
private PhiCycle getCycle(PhiNode phi) { result.getAPhiNode() = phi }
13931389

cpp/ql/test/library-tests/dataflow/certain/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ void test(int x, bool b1, bool b2) { // $ certain="SSA def(&x)" certain="SSA def
6767
int* p = &x; // $ certain="SSA def(&p)" certain="SSA def(p)" certain="SSA def(*p)"
6868
int i = 0; // $ certain="SSA def(&i)" certain="SSA def(i)"
6969
int j = 0; // $ certain="SSA def(&j)" certain="SSA def(j)"
70-
while (i < 10) { // $ certain="SSA phi(i)" uncertain="SSA phi(*p)"
70+
while (i < 10) { // $ certain="SSA phi(i)" certain="SSA phi(*p)"
7171
if (b1) {
7272
*p = 0; // $ certain="SSA def(*p)"
7373
}
74-
++i; // $ certain="SSA def(i)" uncertain="SSA phi(*p)"
74+
++i; // $ certain="SSA def(i)" certain="SSA phi(*p)"
7575
}
7676
while (j < 10) { // $ uncertain="SSA phi(*p)" certain="SSA phi(j)"
7777
if (b2) {

0 commit comments

Comments
 (0)