Skip to content

Commit e8afec4

Browse files
committed
C++: Add testcase that demonstrates a FP caused by spurious flow through phi nodes in IR dataflow.
1 parent 5031d6c commit e8afec4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ postWithInFlow
570570
| test.cpp:481:24:481:30 | FieldAddress [post update] | PostUpdateNode should not be the target of local flow. |
571571
| test.cpp:481:24:481:30 | content [post update] | PostUpdateNode should not be the target of local flow. |
572572
| test.cpp:482:8:482:16 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
573+
| test.cpp:489:7:489:7 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
574+
| test.cpp:491:5:491:5 | x [post update] | PostUpdateNode should not be the target of local flow. |
575+
| test.cpp:494:5:494:5 | x [post update] | PostUpdateNode should not be the target of local flow. |
573576
| true_upon_entry.cpp:9:7:9:7 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
574577
| true_upon_entry.cpp:10:12:10:12 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |
575578
| true_upon_entry.cpp:10:27:10:27 | VariableAddress [post update] | PostUpdateNode should not be the target of local flow. |

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,16 @@ void local_field_flow_def_by_ref_steps_with_local_flow(MyStruct * s) {
481481
writes_to_content(s->content);
482482
int* p_content = s->content;
483483
sink(*p_content);
484-
}
484+
}
485+
486+
bool unknown();
487+
488+
void regression_with_phi_flow(int clean1) {
489+
int x = 0;
490+
while (unknown()) {
491+
x = clean1;
492+
if (unknown()) { }
493+
sink(x); // $ SPURIOUS: ir
494+
x = source();
495+
}
496+
}

0 commit comments

Comments
 (0)