Skip to content

Commit 7998731

Browse files
committed
C++: Add a test that demonstrates reference dereference duplication.
1 parent f8feb84 commit 7998731

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ argHasPostUpdate
2424
| lambdas.cpp:45:2:45:2 | e | ArgumentNode is missing PostUpdateNode. |
2525
| test.cpp:67:29:67:35 | source1 | ArgumentNode is missing PostUpdateNode. |
2626
| test.cpp:813:19:813:35 | * ... | ArgumentNode is missing PostUpdateNode. |
27+
| test.cpp:848:23:848:25 | rpx | ArgumentNode is missing PostUpdateNode. |
2728
postWithInFlow
2829
| BarrierGuard.cpp:49:6:49:6 | x [post update] | PostUpdateNode should not be the target of local flow. |
2930
| BarrierGuard.cpp:60:7:60:7 | x [post update] | PostUpdateNode should not be the target of local flow. |

cpp/ql/test/library-tests/dataflow/dataflow-tests/test-source-sink.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ astFlow
118118
| test.cpp:788:31:788:36 | call to source | test.cpp:782:12:782:12 | x |
119119
| test.cpp:790:31:790:36 | call to source | test.cpp:782:12:782:12 | x |
120120
| test.cpp:797:22:797:28 | ref arg content | test.cpp:798:19:798:25 | content |
121+
| test.cpp:842:11:842:16 | call to source | test.cpp:844:8:844:8 | y |
122+
| test.cpp:846:13:846:27 | call to indirect_source | test.cpp:848:23:848:25 | rpx |
121123
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
122124
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |
123125
| true_upon_entry.cpp:33:11:33:16 | call to source | true_upon_entry.cpp:39:8:39:8 | x |
@@ -278,6 +280,9 @@ irFlow
278280
| test.cpp:808:25:808:39 | call to indirect_source indirection | test.cpp:813:19:813:35 | * ... indirection |
279281
| test.cpp:818:26:818:31 | call to source | test.cpp:823:10:823:27 | * ... |
280282
| test.cpp:832:21:832:26 | call to source | test.cpp:836:10:836:22 | global_direct |
283+
| test.cpp:842:11:842:16 | call to source | test.cpp:844:8:844:8 | y |
284+
| test.cpp:846:13:846:27 | call to indirect_source indirection | test.cpp:848:17:848:25 | rpx indirection |
285+
| test.cpp:846:13:846:27 | call to indirect_source indirection | test.cpp:848:23:848:25 | (reference dereference) indirection |
281286
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |
282287
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
283288
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,4 +836,14 @@ namespace MoreGlobalTests {
836836
sink(global_direct); // $ ir MISSING: ast
837837
indirect_sink(global_direct); // clean
838838
}
839+
}
840+
841+
void test_references() {
842+
int x = source();
843+
int &y = x;
844+
sink(y); // $ ast,ir
845+
846+
int* px = indirect_source();
847+
int*& rpx = px;
848+
indirect_sink((int*)rpx); // $ ast,ir
839849
}

0 commit comments

Comments
 (0)