Skip to content

Commit a3d3617

Browse files
committed
C++: Add tests with missing flow.
1 parent 9c039c4 commit a3d3617

File tree

8 files changed

+228
-0
lines changed

8 files changed

+228
-0
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
@@ -32,6 +32,10 @@ argHasPostUpdate
3232
| test.cpp:67:29:67:35 | source1 | ArgumentNode is missing PostUpdateNode. |
3333
| test.cpp:813:19:813:35 | * ... | ArgumentNode is missing PostUpdateNode. |
3434
| test.cpp:848:23:848:25 | rpx | ArgumentNode is missing PostUpdateNode. |
35+
| test.cpp:972:19:972:37 | * ... | ArgumentNode is missing PostUpdateNode. |
36+
| test.cpp:973:10:973:28 | * ... | ArgumentNode is missing PostUpdateNode. |
37+
| test.cpp:990:19:990:37 | * ... | ArgumentNode is missing PostUpdateNode. |
38+
| test.cpp:991:10:991:28 | * ... | ArgumentNode is missing PostUpdateNode. |
3539
postWithInFlow
3640
| BarrierGuard.cpp:49:6:49:6 | x [post update] | PostUpdateNode should not be the target of local flow. |
3741
| BarrierGuard.cpp:60:7:60:7 | x [post update] | PostUpdateNode should not be the target of local flow. |
@@ -159,6 +163,10 @@ postWithInFlow
159163
| test.cpp:808:5:808:21 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
160164
| test.cpp:808:6:808:21 | global_indirect1 [inner post update] | PostUpdateNode should not be the target of local flow. |
161165
| test.cpp:832:5:832:17 | global_direct [post update] | PostUpdateNode should not be the target of local flow. |
166+
| test.cpp:931:5:931:6 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
167+
| test.cpp:931:6:931:6 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
168+
| test.cpp:961:5:961:6 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
169+
| test.cpp:961:6:961:6 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
162170
viableImplInCallContextTooLarge
163171
uniqueParameterNodeAtPosition
164172
uniqueParameterNodePosition

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ astFlow
123123
| test.cpp:842:11:842:16 | call to source | test.cpp:844:8:844:8 | y |
124124
| test.cpp:846:13:846:27 | call to indirect_source | test.cpp:848:23:848:25 | rpx |
125125
| test.cpp:860:54:860:59 | call to source | test.cpp:861:10:861:37 | static_local_pointer_dynamic |
126+
| test.cpp:931:10:931:15 | call to source | test.cpp:936:19:936:32 | global_int_ptr |
127+
| test.cpp:931:10:931:15 | call to source | test.cpp:1000:19:1000:34 | global_int_array |
128+
| test.cpp:931:10:931:15 | call to source | test.cpp:1005:10:1005:26 | * ... |
129+
| test.cpp:961:10:961:24 | call to indirect_source | test.cpp:966:19:966:36 | global_int_ptr_ptr |
130+
| test.cpp:961:10:961:24 | call to indirect_source | test.cpp:967:10:967:27 | global_int_ptr_ptr |
126131
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
127132
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |
128133
| true_upon_entry.cpp:33:11:33:16 | call to source | true_upon_entry.cpp:39:8:39:8 | x |
@@ -300,6 +305,13 @@ irFlow
300305
| test.cpp:902:56:902:75 | *indirect_source(2) | test.cpp:911:19:911:48 | *global_array_static_indirect_2 |
301306
| test.cpp:914:46:914:53 | source | test.cpp:919:10:919:30 | global_pointer_static |
302307
| test.cpp:915:57:915:76 | *indirect_source(1) | test.cpp:921:19:921:50 | *global_pointer_static_indirect_1 |
308+
| test.cpp:931:10:931:15 | call to source | test.cpp:936:19:936:32 | *global_int_ptr |
309+
| test.cpp:931:10:931:15 | call to source | test.cpp:941:10:941:24 | * ... |
310+
| test.cpp:931:10:931:15 | call to source | test.cpp:1000:19:1000:34 | *global_int_array |
311+
| test.cpp:931:10:931:15 | call to source | test.cpp:1005:10:1005:26 | * ... |
312+
| test.cpp:961:10:961:24 | *call to indirect_source | test.cpp:966:19:966:36 | **global_int_ptr_ptr |
313+
| test.cpp:961:10:961:24 | *call to indirect_source | test.cpp:972:19:972:37 | ** ... |
314+
| test.cpp:961:10:961:24 | *call to indirect_source | test.cpp:975:10:975:29 | * ... |
303315
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |
304316
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
305317
| 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: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,4 +922,100 @@ namespace GlobalArrays {
922922
sink(global_pointer_static_indirect_2); // clean: global_pointer_static_indirect_2 does not have 2 indirections
923923
indirect_sink(global_pointer_static_indirect_2); // clean: global_pointer_static_indirect_2 does not have 2 indirections
924924
}
925+
}
926+
927+
namespace globals_without_explicit_def {
928+
int* global_int_ptr;
929+
930+
void set(int* p) { // $ ast-def=p ir-def=*p
931+
*p = source();
932+
}
933+
934+
void test1() {
935+
set(global_int_ptr);
936+
indirect_sink(global_int_ptr); // $ ir,ast
937+
}
938+
939+
void test2() {
940+
set(global_int_ptr);
941+
sink(*global_int_ptr); // $ ir MISSING: ast
942+
}
943+
944+
void calls_set() {
945+
set(global_int_ptr);
946+
}
947+
948+
void test3() {
949+
calls_set();
950+
indirect_sink(global_int_ptr); // $ MISSING: ast,ir
951+
}
952+
953+
void test4() {
954+
calls_set();
955+
sink(*global_int_ptr); // $ MISSING: ast,ir
956+
}
957+
958+
int** global_int_ptr_ptr;
959+
960+
void set_indirect(int** p) { // $ ast-def=p ir-def=*p ir-def=**p
961+
*p = indirect_source();
962+
}
963+
964+
void test5() {
965+
set_indirect(global_int_ptr_ptr);
966+
indirect_sink(global_int_ptr_ptr); // $ ir,ast
967+
sink(global_int_ptr_ptr); // $ SPURIOUS: ast
968+
}
969+
970+
void test6() {
971+
set_indirect(global_int_ptr_ptr);
972+
indirect_sink(*global_int_ptr_ptr); // $ ir MISSING: ast
973+
sink(*global_int_ptr_ptr);
974+
indirect_sink(**global_int_ptr_ptr);
975+
sink(**global_int_ptr_ptr); // $ ir
976+
}
977+
978+
void calls_set_indirect() {
979+
set_indirect(global_int_ptr_ptr);
980+
}
981+
982+
void test7() {
983+
calls_set_indirect();
984+
indirect_sink(global_int_ptr_ptr); // $ MISSING: ast,ir
985+
sink(global_int_ptr_ptr); // $ MISSING: ast
986+
}
987+
988+
void test8() {
989+
calls_set_indirect();
990+
indirect_sink(*global_int_ptr_ptr); // $ MISSING: ast,ir
991+
sink(*global_int_ptr_ptr);
992+
indirect_sink(**global_int_ptr_ptr);
993+
sink(**global_int_ptr_ptr); // $ MISSING: ast,ir
994+
}
995+
996+
int global_int_array[10];
997+
998+
void test9() {
999+
set(global_int_array);
1000+
indirect_sink(global_int_array); // $ ir,ast
1001+
}
1002+
1003+
void test10() {
1004+
set(global_int_array);
1005+
sink(*global_int_array); // $ ir,ast
1006+
}
1007+
1008+
void calls_set_array() {
1009+
set(global_int_array);
1010+
}
1011+
1012+
void test11() {
1013+
calls_set_array();
1014+
indirect_sink(global_int_array); // $ MISSING: ast,ir
1015+
}
1016+
1017+
void test12() {
1018+
calls_set_array();
1019+
sink(*global_int_array); // $ MISSING: ast,ir
1020+
}
9251021
}

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,64 @@ void deep_member_field_arrow(S2 *ps2) {
204204
void deep_member_field_arrow_different_fields(S2 *ps2) {
205205
taint_a_ptr(&ps2->s.m1);
206206
sink(ps2->s.m2);
207+
}
208+
209+
namespace GlobalFieldFlow {
210+
S global_s;
211+
S2 global_s2;
212+
213+
void set_field() {
214+
global_s.m1 = user_input();
215+
}
216+
217+
void read_field() {
218+
sink(global_s.m1); // $ MISSING: ast,ir
219+
}
220+
221+
void set_nested_field() {
222+
global_s2.s.m1 = user_input();
223+
}
224+
225+
void read_nested_field() {
226+
sink(global_s2.s.m1); // $ MISSING: ast,ir
227+
}
228+
229+
S* global_s_ptr;
230+
S2* global_s2_ptr;
231+
232+
void set_field_ptr() {
233+
global_s_ptr->m1 = user_input();
234+
}
235+
236+
void read_field_ptr() {
237+
sink(global_s_ptr->m1); // $ MISSING: ast,ir
238+
}
239+
240+
void set_nested_field_ptr() {
241+
global_s2_ptr->s.m1 = user_input();
242+
}
243+
244+
void read_nested_field_ptr() {
245+
sink(global_s2_ptr->s.m1); // $ MISSING: ast,ir
246+
}
247+
248+
S_with_pointer global_s_with_pointer;
249+
250+
void set_field_indirect() {
251+
*global_s_with_pointer.data = user_input();
252+
}
253+
254+
void read_field_indirect() {
255+
sink(*global_s_with_pointer.data); // $ MISSING: ast,ir
256+
}
257+
258+
S_with_array global_s_with_array;
259+
260+
void set_field_array() {
261+
*global_s_with_array.data = user_input();
262+
}
263+
264+
void read_field_array() {
265+
sink(*global_s_with_array.data); // $ MISSING: ast,ir
266+
}
207267
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ postWithInFlow
9595
| aliasing.cpp:194:21:194:22 | m1 [inner post update] | PostUpdateNode should not be the target of local flow. |
9696
| aliasing.cpp:200:23:200:24 | m1 [inner post update] | PostUpdateNode should not be the target of local flow. |
9797
| aliasing.cpp:205:23:205:24 | m1 [inner post update] | PostUpdateNode should not be the target of local flow. |
98+
| aliasing.cpp:214:14:214:15 | m1 [post update] | PostUpdateNode should not be the target of local flow. |
99+
| aliasing.cpp:222:17:222:18 | m1 [post update] | PostUpdateNode should not be the target of local flow. |
100+
| aliasing.cpp:233:19:233:20 | m1 [post update] | PostUpdateNode should not be the target of local flow. |
101+
| aliasing.cpp:241:22:241:23 | m1 [post update] | PostUpdateNode should not be the target of local flow. |
102+
| aliasing.cpp:251:5:251:31 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
103+
| aliasing.cpp:251:28:251:31 | data [inner post update] | PostUpdateNode should not be the target of local flow. |
104+
| aliasing.cpp:261:5:261:29 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
105+
| aliasing.cpp:261:26:261:29 | data [inner post update] | PostUpdateNode should not be the target of local flow. |
98106
| arrays.cpp:6:3:6:5 | arr [inner post update] | PostUpdateNode should not be the target of local flow. |
99107
| arrays.cpp:6:3:6:8 | access to array [post update] | PostUpdateNode should not be the target of local flow. |
100108
| arrays.cpp:15:3:15:10 | * ... [post update] | PostUpdateNode should not be the target of local flow. |

cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ WARNING: Module DataFlow has been deprecated and may be removed in future (parti
141141
| aliasing.cpp:201:13:201:13 | s | IR only |
142142
| aliasing.cpp:206:8:206:10 | ps2 | IR only |
143143
| aliasing.cpp:206:13:206:13 | s | IR only |
144+
| aliasing.cpp:214:14:214:15 | m1 | AST only |
145+
| aliasing.cpp:218:10:218:17 | global_s | IR only |
146+
| aliasing.cpp:222:17:222:18 | m1 | AST only |
147+
| aliasing.cpp:226:10:226:18 | global_s2 | IR only |
148+
| aliasing.cpp:226:20:226:20 | s | IR only |
149+
| aliasing.cpp:233:19:233:20 | m1 | AST only |
150+
| aliasing.cpp:237:10:237:21 | global_s_ptr | IR only |
151+
| aliasing.cpp:241:22:241:23 | m1 | AST only |
152+
| aliasing.cpp:245:10:245:22 | global_s2_ptr | IR only |
153+
| aliasing.cpp:245:25:245:25 | s | IR only |
154+
| aliasing.cpp:251:5:251:31 | * ... | AST only |
155+
| aliasing.cpp:255:11:255:31 | global_s_with_pointer | IR only |
156+
| aliasing.cpp:261:5:261:29 | * ... | AST only |
157+
| aliasing.cpp:265:11:265:29 | global_s_with_array | IR only |
144158
| arrays.cpp:6:3:6:8 | access to array | AST only |
145159
| arrays.cpp:7:8:7:13 | access to array | IR only |
146160
| arrays.cpp:7:8:7:13 | access to array | IR only |

cpp/ql/test/library-tests/dataflow/fields/partial-definition-ir.expected

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,22 @@
285285
| aliasing.cpp:205:21:205:21 | s |
286286
| aliasing.cpp:206:8:206:10 | ps2 |
287287
| aliasing.cpp:206:13:206:13 | s |
288+
| aliasing.cpp:214:5:214:12 | global_s |
289+
| aliasing.cpp:218:10:218:17 | global_s |
290+
| aliasing.cpp:222:5:222:13 | global_s2 |
291+
| aliasing.cpp:222:15:222:15 | s |
292+
| aliasing.cpp:226:10:226:18 | global_s2 |
293+
| aliasing.cpp:226:20:226:20 | s |
294+
| aliasing.cpp:233:5:233:16 | global_s_ptr |
295+
| aliasing.cpp:237:10:237:21 | global_s_ptr |
296+
| aliasing.cpp:241:5:241:17 | global_s2_ptr |
297+
| aliasing.cpp:241:20:241:20 | s |
298+
| aliasing.cpp:245:10:245:22 | global_s2_ptr |
299+
| aliasing.cpp:245:25:245:25 | s |
300+
| aliasing.cpp:251:6:251:26 | global_s_with_pointer |
301+
| aliasing.cpp:255:11:255:31 | global_s_with_pointer |
302+
| aliasing.cpp:261:6:261:24 | global_s_with_array |
303+
| aliasing.cpp:265:11:265:29 | global_s_with_array |
288304
| arrays.cpp:7:8:7:13 | access to array |
289305
| arrays.cpp:8:8:8:13 | access to array |
290306
| arrays.cpp:9:8:9:11 | * ... |

cpp/ql/test/library-tests/dataflow/fields/partial-definition.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,20 @@ WARNING: Module DataFlow has been deprecated and may be removed in future (parti
225225
| aliasing.cpp:205:15:205:24 | & ... |
226226
| aliasing.cpp:205:16:205:18 | ps2 |
227227
| aliasing.cpp:205:21:205:21 | s |
228+
| aliasing.cpp:214:5:214:12 | global_s |
229+
| aliasing.cpp:214:14:214:15 | m1 |
230+
| aliasing.cpp:222:5:222:13 | global_s2 |
231+
| aliasing.cpp:222:15:222:15 | s |
232+
| aliasing.cpp:222:17:222:18 | m1 |
233+
| aliasing.cpp:233:5:233:16 | global_s_ptr |
234+
| aliasing.cpp:233:19:233:20 | m1 |
235+
| aliasing.cpp:241:5:241:17 | global_s2_ptr |
236+
| aliasing.cpp:241:20:241:20 | s |
237+
| aliasing.cpp:241:22:241:23 | m1 |
238+
| aliasing.cpp:251:5:251:31 | * ... |
239+
| aliasing.cpp:251:6:251:26 | global_s_with_pointer |
240+
| aliasing.cpp:261:5:261:29 | * ... |
241+
| aliasing.cpp:261:6:261:24 | global_s_with_array |
228242
| arrays.cpp:6:3:6:8 | access to array |
229243
| arrays.cpp:15:3:15:10 | * ... |
230244
| arrays.cpp:36:3:36:3 | o |

0 commit comments

Comments
 (0)