Skip to content

Commit c389611

Browse files
committed
C++: Add spurious dataflow test.
1 parent b8e6632 commit c389611

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ argHasPostUpdate
3333
| test.cpp:67:29:67:35 | source1 | ArgumentNode is missing PostUpdateNode. |
3434
| test.cpp:813:19:813:35 | * ... | ArgumentNode is missing PostUpdateNode. |
3535
| test.cpp:848:23:848:25 | rpx | ArgumentNode is missing PostUpdateNode. |
36+
| test.cpp:1057:19:1057:21 | * ... | ArgumentNode is missing PostUpdateNode. |
3637
postWithInFlow
3738
| BarrierGuard.cpp:49:6:49:6 | x [post update] | PostUpdateNode should not be the target of local flow. |
3839
| BarrierGuard.cpp:60:7:60:7 | x [post update] | PostUpdateNode should not be the target of local flow. |
@@ -168,6 +169,13 @@ postWithInFlow
168169
| test.cpp:1045:9:1045:11 | ref arg buf | PostUpdateNode should not be the target of local flow. |
169170
| test.cpp:1051:5:1051:11 | content [post update] | PostUpdateNode should not be the target of local flow. |
170171
| test.cpp:1052:9:1052:9 | a [inner post update] | PostUpdateNode should not be the target of local flow. |
172+
| test.cpp:1056:5:1056:7 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
173+
| test.cpp:1056:6:1056:7 | pp [inner post update] | PostUpdateNode should not be the target of local flow. |
174+
| test.cpp:1062:53:1062:53 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
175+
| test.cpp:1072:3:1072:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
176+
| test.cpp:1072:4:1072:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
177+
| test.cpp:1073:3:1073:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
178+
| test.cpp:1073:4:1073:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
171179
viableImplInCallContextTooLarge
172180
uniqueParameterNodeAtPosition
173181
uniqueParameterNodePosition

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ irFlow
310310
| test.cpp:1021:18:1021:32 | *call to indirect_source | test.cpp:1027:19:1027:28 | *translated |
311311
| test.cpp:1021:18:1021:32 | *call to indirect_source | test.cpp:1031:19:1031:28 | *translated |
312312
| test.cpp:1045:14:1045:19 | call to source | test.cpp:1046:7:1046:10 | * ... |
313+
| test.cpp:1061:15:1061:38 | *call to indirect_source | test.cpp:1057:19:1057:21 | ** ... |
314+
| test.cpp:1072:8:1072:13 | call to source | test.cpp:1074:8:1074:9 | * ... |
313315
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |
314316
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
315317
| 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: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,4 +1050,26 @@ void flow_out_of_address_with_local_flow() {
10501050
MyStruct a;
10511051
a.content = nullptr;
10521052
sink(&a); // $ SPURIOUS: ast
1053-
}
1053+
}
1054+
1055+
static void static_func_that_reassigns_pointer_before_sink(char** pp) { // $ ast-def=pp ir-def=*pp ir-def=**pp
1056+
*pp = "";
1057+
indirect_sink(*pp); // $ SPURIOUS: ir
1058+
}
1059+
1060+
void test_static_func_that_reassigns_pointer_before_sink() {
1061+
char* p = (char*)indirect_source();
1062+
static_func_that_reassigns_pointer_before_sink(&p);
1063+
}
1064+
1065+
void single_object_in_both_cases(bool b, int x, int y) {
1066+
int* p;
1067+
if(b) {
1068+
p = &x;
1069+
} else {
1070+
p = &y;
1071+
}
1072+
*p = source();
1073+
*p = 0;
1074+
sink(*p); // $ SPURIOUS: ir
1075+
}

cpp/ql/test/library-tests/dataflow/dataflow-tests/type-bugs.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ incorrectBaseType
1515
| test.cpp:848:23:848:25 | (reference dereference) | Expected 'Node.getType()' to be int, but it was int * |
1616
| test.cpp:854:10:854:36 | * ... | Expected 'Node.getType()' to be const int, but it was int |
1717
| test.cpp:867:10:867:30 | * ... | Expected 'Node.getType()' to be const int, but it was int |
18+
| test.cpp:1062:52:1062:53 | *& ... | Expected 'Node.getType()' to be char, but it was char * |
1819
failures

0 commit comments

Comments
 (0)