Skip to content

Commit 0caa17a

Browse files
committed
C++: Test the new methods.
1 parent 52e501c commit 0caa17a

File tree

6 files changed

+154
-2
lines changed

6 files changed

+154
-2
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,37 @@
510510
| swap1.cpp:113:31:113:39 | ref arg call to move | swap1.cpp:113:41:113:49 | move_from [inner post update] | |
511511
| swap1.cpp:113:31:113:51 | call to Class | swap1.cpp:115:10:115:16 | move_to | |
512512
| swap1.cpp:113:41:113:49 | move_from | swap1.cpp:113:31:113:39 | call to move | |
513+
| swap1.cpp:120:23:120:23 | x | swap1.cpp:122:5:122:5 | x | |
514+
| swap1.cpp:120:23:120:23 | x | swap1.cpp:124:10:124:10 | x | |
515+
| swap1.cpp:120:23:120:23 | x | swap1.cpp:127:19:127:19 | x | |
516+
| swap1.cpp:120:23:120:23 | x | swap1.cpp:130:10:130:10 | x | |
517+
| swap1.cpp:121:23:121:23 | y | swap1.cpp:125:10:125:10 | y | |
518+
| swap1.cpp:121:23:121:23 | y | swap1.cpp:127:5:127:5 | y | |
519+
| swap1.cpp:121:23:121:23 | y | swap1.cpp:129:10:129:10 | y | |
520+
| swap1.cpp:122:5:122:5 | x [post update] | swap1.cpp:124:10:124:10 | x | |
521+
| swap1.cpp:122:5:122:5 | x [post update] | swap1.cpp:127:19:127:19 | x | |
522+
| swap1.cpp:122:5:122:5 | x [post update] | swap1.cpp:130:10:130:10 | x | |
523+
| swap1.cpp:122:5:122:22 | ... = ... | swap1.cpp:124:12:124:16 | data1 | |
524+
| swap1.cpp:122:5:122:22 | ... = ... | swap1.cpp:130:12:130:16 | data1 | |
525+
| swap1.cpp:122:15:122:20 | call to source | swap1.cpp:122:5:122:22 | ... = ... | |
526+
| swap1.cpp:127:5:127:5 | ref arg y | swap1.cpp:129:10:129:10 | y | |
527+
| swap1.cpp:135:23:135:23 | x | swap1.cpp:137:5:137:5 | x | |
528+
| swap1.cpp:135:23:135:23 | x | swap1.cpp:139:10:139:10 | x | |
529+
| swap1.cpp:135:23:135:23 | x | swap1.cpp:142:29:142:29 | x | |
530+
| swap1.cpp:135:23:135:23 | x | swap1.cpp:145:10:145:10 | x | |
531+
| swap1.cpp:136:23:136:23 | y | swap1.cpp:140:10:140:10 | y | |
532+
| swap1.cpp:136:23:136:23 | y | swap1.cpp:142:5:142:5 | y | |
533+
| swap1.cpp:136:23:136:23 | y | swap1.cpp:144:10:144:10 | y | |
534+
| swap1.cpp:137:5:137:5 | x [post update] | swap1.cpp:139:10:139:10 | x | |
535+
| swap1.cpp:137:5:137:5 | x [post update] | swap1.cpp:142:29:142:29 | x | |
536+
| swap1.cpp:137:5:137:5 | x [post update] | swap1.cpp:145:10:145:10 | x | |
537+
| swap1.cpp:137:5:137:22 | ... = ... | swap1.cpp:139:12:139:16 | data1 | |
538+
| swap1.cpp:137:5:137:22 | ... = ... | swap1.cpp:145:12:145:16 | data1 | |
539+
| swap1.cpp:137:15:137:20 | call to source | swap1.cpp:137:5:137:22 | ... = ... | |
540+
| swap1.cpp:142:5:142:5 | ref arg y | swap1.cpp:144:10:144:10 | y | |
541+
| swap1.cpp:142:19:142:27 | ref arg call to move | swap1.cpp:142:29:142:29 | x [inner post update] | |
542+
| swap1.cpp:142:19:142:27 | ref arg call to move | swap1.cpp:145:10:145:10 | x | |
543+
| swap1.cpp:142:29:142:29 | x | swap1.cpp:142:19:142:27 | call to move | |
513544
| swap2.cpp:14:17:14:17 | t | swap2.cpp:14:17:14:17 | t | |
514545
| swap2.cpp:14:17:14:17 | t | swap2.cpp:14:17:14:17 | t | |
515546
| swap2.cpp:14:17:14:17 | t | swap2.cpp:14:56:14:56 | t | |
@@ -645,6 +676,37 @@
645676
| swap2.cpp:113:31:113:39 | ref arg call to move | swap2.cpp:113:41:113:49 | move_from [inner post update] | |
646677
| swap2.cpp:113:31:113:51 | call to Class | swap2.cpp:115:10:115:16 | move_to | |
647678
| swap2.cpp:113:41:113:49 | move_from | swap2.cpp:113:31:113:39 | call to move | |
679+
| swap2.cpp:120:23:120:23 | x | swap2.cpp:122:5:122:5 | x | |
680+
| swap2.cpp:120:23:120:23 | x | swap2.cpp:124:10:124:10 | x | |
681+
| swap2.cpp:120:23:120:23 | x | swap2.cpp:127:19:127:19 | x | |
682+
| swap2.cpp:120:23:120:23 | x | swap2.cpp:130:10:130:10 | x | |
683+
| swap2.cpp:121:23:121:23 | y | swap2.cpp:125:10:125:10 | y | |
684+
| swap2.cpp:121:23:121:23 | y | swap2.cpp:127:5:127:5 | y | |
685+
| swap2.cpp:121:23:121:23 | y | swap2.cpp:129:10:129:10 | y | |
686+
| swap2.cpp:122:5:122:5 | x [post update] | swap2.cpp:124:10:124:10 | x | |
687+
| swap2.cpp:122:5:122:5 | x [post update] | swap2.cpp:127:19:127:19 | x | |
688+
| swap2.cpp:122:5:122:5 | x [post update] | swap2.cpp:130:10:130:10 | x | |
689+
| swap2.cpp:122:5:122:22 | ... = ... | swap2.cpp:124:12:124:16 | data1 | |
690+
| swap2.cpp:122:5:122:22 | ... = ... | swap2.cpp:130:12:130:16 | data1 | |
691+
| swap2.cpp:122:15:122:20 | call to source | swap2.cpp:122:5:122:22 | ... = ... | |
692+
| swap2.cpp:127:5:127:5 | ref arg y | swap2.cpp:129:10:129:10 | y | |
693+
| swap2.cpp:135:23:135:23 | x | swap2.cpp:137:5:137:5 | x | |
694+
| swap2.cpp:135:23:135:23 | x | swap2.cpp:139:10:139:10 | x | |
695+
| swap2.cpp:135:23:135:23 | x | swap2.cpp:142:29:142:29 | x | |
696+
| swap2.cpp:135:23:135:23 | x | swap2.cpp:145:10:145:10 | x | |
697+
| swap2.cpp:136:23:136:23 | y | swap2.cpp:140:10:140:10 | y | |
698+
| swap2.cpp:136:23:136:23 | y | swap2.cpp:142:5:142:5 | y | |
699+
| swap2.cpp:136:23:136:23 | y | swap2.cpp:144:10:144:10 | y | |
700+
| swap2.cpp:137:5:137:5 | x [post update] | swap2.cpp:139:10:139:10 | x | |
701+
| swap2.cpp:137:5:137:5 | x [post update] | swap2.cpp:142:29:142:29 | x | |
702+
| swap2.cpp:137:5:137:5 | x [post update] | swap2.cpp:145:10:145:10 | x | |
703+
| swap2.cpp:137:5:137:22 | ... = ... | swap2.cpp:139:12:139:16 | data1 | |
704+
| swap2.cpp:137:5:137:22 | ... = ... | swap2.cpp:145:12:145:16 | data1 | |
705+
| swap2.cpp:137:15:137:20 | call to source | swap2.cpp:137:5:137:22 | ... = ... | |
706+
| swap2.cpp:142:5:142:5 | ref arg y | swap2.cpp:144:10:144:10 | y | |
707+
| swap2.cpp:142:19:142:27 | ref arg call to move | swap2.cpp:142:29:142:29 | x [inner post update] | |
708+
| swap2.cpp:142:19:142:27 | ref arg call to move | swap2.cpp:145:10:145:10 | x | |
709+
| swap2.cpp:142:29:142:29 | x | swap2.cpp:142:19:142:27 | call to move | |
648710
| taint.cpp:4:27:4:33 | source1 | taint.cpp:6:13:6:19 | source1 | |
649711
| taint.cpp:4:40:4:45 | clean1 | taint.cpp:5:8:5:13 | clean1 | |
650712
| taint.cpp:4:40:4:45 | clean1 | taint.cpp:6:3:6:8 | clean1 | |

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,33 @@ void test_move_constructor()
114114

115115
sink(move_to.data1); // tainted
116116
}
117+
118+
void test_copy_assignment_method()
119+
{
120+
IntWrapper::Class x;
121+
IntWrapper::Class y;
122+
x.data1 = source();
123+
124+
sink(x.data1); // tainted
125+
sink(y.data1); // clean
126+
127+
y.copy_assign(x);
128+
129+
sink(y.data1); // tainted
130+
sink(x.data1); // tainted
131+
}
132+
133+
void test_move_assignment_method()
134+
{
135+
IntWrapper::Class x;
136+
IntWrapper::Class y;
137+
x.data1 = source();
138+
139+
sink(x.data1); // tainted
140+
sink(y.data1); // clean
141+
142+
y.move_assign(std::move(x));
143+
144+
sink(y.data1); // tainted
145+
sink(x.data1); // tainted
146+
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,33 @@ void test_move_constructor()
114114

115115
sink(move_to.data1); // tainted
116116
}
117+
118+
void test_copy_assignment_method()
119+
{
120+
IntWrapper::Class x;
121+
IntWrapper::Class y;
122+
x.data1 = source();
123+
124+
sink(x.data1); // tainted
125+
sink(y.data1); // clean
126+
127+
y.copy_assign(x);
128+
129+
sink(y.data1); // tainted
130+
sink(x.data1); // tainted
131+
}
132+
133+
void test_move_assignment_method()
134+
{
135+
IntWrapper::Class x;
136+
IntWrapper::Class y;
137+
x.data1 = source();
138+
139+
sink(x.data1); // tainted
140+
sink(y.data1); // clean
141+
142+
y.move_assign(std::move(x));
143+
144+
sink(y.data1); // tainted
145+
sink(x.data1); // tainted
146+
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,19 @@
6161
| swap1.cpp:111:20:111:24 | data1 | swap1.cpp:109:23:109:28 | call to source |
6262
| swap1.cpp:115:18:115:22 | data1 | swap1.cpp:108:23:108:31 | move_from |
6363
| swap1.cpp:115:18:115:22 | data1 | swap1.cpp:109:23:109:28 | call to source |
64+
| swap1.cpp:124:12:124:16 | data1 | swap1.cpp:122:15:122:20 | call to source |
65+
| swap1.cpp:129:12:129:16 | data1 | swap1.cpp:120:23:120:23 | x |
66+
| swap1.cpp:129:12:129:16 | data1 | swap1.cpp:122:15:122:20 | call to source |
67+
| swap1.cpp:130:12:130:16 | data1 | swap1.cpp:122:15:122:20 | call to source |
68+
| swap1.cpp:139:12:139:16 | data1 | swap1.cpp:137:15:137:20 | call to source |
69+
| swap1.cpp:144:12:144:16 | data1 | swap1.cpp:135:23:135:23 | x |
70+
| swap1.cpp:144:12:144:16 | data1 | swap1.cpp:137:15:137:20 | call to source |
71+
| swap1.cpp:145:12:145:16 | data1 | swap1.cpp:137:15:137:20 | call to source |
6472
| swap2.cpp:73:12:73:16 | data1 | swap2.cpp:71:15:71:20 | call to source |
6573
| swap2.cpp:78:12:78:16 | data1 | swap2.cpp:69:23:69:23 | x |
6674
| swap2.cpp:78:12:78:16 | data1 | swap2.cpp:71:15:71:20 | call to source |
6775
| swap2.cpp:79:12:79:16 | data1 | swap2.cpp:71:15:71:20 | call to source |
6876
| swap2.cpp:83:13:83:17 | data1 | swap2.cpp:82:16:82:21 | call to source |
69-
| swap2.cpp:87:13:87:17 | data1 | swap2.cpp:82:16:82:21 | call to source |
7077
| swap2.cpp:88:13:88:17 | data1 | swap2.cpp:81:27:81:28 | z2 |
7178
| swap2.cpp:88:13:88:17 | data1 | swap2.cpp:82:16:82:21 | call to source |
7279
| swap2.cpp:97:12:97:16 | data1 | swap2.cpp:95:15:95:20 | call to source |
@@ -76,6 +83,14 @@
7683
| swap2.cpp:111:20:111:24 | data1 | swap2.cpp:109:23:109:28 | call to source |
7784
| swap2.cpp:115:18:115:22 | data1 | swap2.cpp:108:23:108:31 | move_from |
7885
| swap2.cpp:115:18:115:22 | data1 | swap2.cpp:109:23:109:28 | call to source |
86+
| swap2.cpp:124:12:124:16 | data1 | swap2.cpp:122:15:122:20 | call to source |
87+
| swap2.cpp:129:12:129:16 | data1 | swap2.cpp:120:23:120:23 | x |
88+
| swap2.cpp:129:12:129:16 | data1 | swap2.cpp:122:15:122:20 | call to source |
89+
| swap2.cpp:130:12:130:16 | data1 | swap2.cpp:122:15:122:20 | call to source |
90+
| swap2.cpp:139:12:139:16 | data1 | swap2.cpp:137:15:137:20 | call to source |
91+
| swap2.cpp:144:12:144:16 | data1 | swap2.cpp:135:23:135:23 | x |
92+
| swap2.cpp:144:12:144:16 | data1 | swap2.cpp:137:15:137:20 | call to source |
93+
| swap2.cpp:145:12:145:16 | data1 | swap2.cpp:137:15:137:20 | call to source |
7994
| taint.cpp:8:8:8:13 | clean1 | taint.cpp:4:27:4:33 | source1 |
8095
| taint.cpp:16:8:16:14 | source1 | taint.cpp:12:22:12:27 | call to source |
8196
| taint.cpp:17:8:17:16 | ++ ... | taint.cpp:12:22:12:27 | call to source |

cpp/ql/test/library-tests/dataflow/taint-tests/test_diff.expected

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545
| swap1.cpp:88:13:88:17 | swap1.cpp:81:27:81:28 | AST only |
4646
| swap1.cpp:102:12:102:16 | swap1.cpp:93:23:93:23 | AST only |
4747
| swap1.cpp:115:18:115:22 | swap1.cpp:108:23:108:31 | AST only |
48+
| swap1.cpp:129:12:129:16 | swap1.cpp:120:23:120:23 | AST only |
49+
| swap1.cpp:144:12:144:16 | swap1.cpp:135:23:135:23 | AST only |
4850
| swap2.cpp:78:12:78:16 | swap2.cpp:69:23:69:23 | AST only |
49-
| swap2.cpp:87:13:87:17 | swap2.cpp:82:16:82:21 | AST only |
5051
| swap2.cpp:88:13:88:17 | swap2.cpp:81:27:81:28 | AST only |
5152
| swap2.cpp:102:12:102:16 | swap2.cpp:93:23:93:23 | AST only |
5253
| swap2.cpp:115:18:115:22 | swap2.cpp:108:23:108:31 | AST only |
54+
| swap2.cpp:129:12:129:16 | swap2.cpp:120:23:120:23 | AST only |
55+
| swap2.cpp:144:12:144:16 | swap2.cpp:135:23:135:23 | AST only |
5356
| taint.cpp:41:7:41:13 | taint.cpp:35:12:35:17 | AST only |
5457
| taint.cpp:42:7:42:13 | taint.cpp:35:12:35:17 | AST only |
5558
| taint.cpp:43:7:43:13 | taint.cpp:37:22:37:27 | AST only |

cpp/ql/test/library-tests/dataflow/taint-tests/test_ir.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
| swap1.cpp:103:12:103:16 | data1 | swap1.cpp:95:15:95:20 | call to source |
1919
| swap1.cpp:111:20:111:24 | data1 | swap1.cpp:109:23:109:28 | call to source |
2020
| swap1.cpp:115:18:115:22 | data1 | swap1.cpp:109:23:109:28 | call to source |
21+
| swap1.cpp:124:12:124:16 | data1 | swap1.cpp:122:15:122:20 | call to source |
22+
| swap1.cpp:129:12:129:16 | data1 | swap1.cpp:122:15:122:20 | call to source |
23+
| swap1.cpp:130:12:130:16 | data1 | swap1.cpp:122:15:122:20 | call to source |
24+
| swap1.cpp:139:12:139:16 | data1 | swap1.cpp:137:15:137:20 | call to source |
25+
| swap1.cpp:144:12:144:16 | data1 | swap1.cpp:137:15:137:20 | call to source |
26+
| swap1.cpp:145:12:145:16 | data1 | swap1.cpp:137:15:137:20 | call to source |
2127
| swap2.cpp:73:12:73:16 | data1 | swap2.cpp:71:15:71:20 | call to source |
2228
| swap2.cpp:78:12:78:16 | data1 | swap2.cpp:71:15:71:20 | call to source |
2329
| swap2.cpp:79:12:79:16 | data1 | swap2.cpp:71:15:71:20 | call to source |
@@ -28,6 +34,12 @@
2834
| swap2.cpp:103:12:103:16 | data1 | swap2.cpp:95:15:95:20 | call to source |
2935
| swap2.cpp:111:20:111:24 | data1 | swap2.cpp:109:23:109:28 | call to source |
3036
| swap2.cpp:115:18:115:22 | data1 | swap2.cpp:109:23:109:28 | call to source |
37+
| swap2.cpp:124:12:124:16 | data1 | swap2.cpp:122:15:122:20 | call to source |
38+
| swap2.cpp:129:12:129:16 | data1 | swap2.cpp:122:15:122:20 | call to source |
39+
| swap2.cpp:130:12:130:16 | data1 | swap2.cpp:122:15:122:20 | call to source |
40+
| swap2.cpp:139:12:139:16 | data1 | swap2.cpp:137:15:137:20 | call to source |
41+
| swap2.cpp:144:12:144:16 | data1 | swap2.cpp:137:15:137:20 | call to source |
42+
| swap2.cpp:145:12:145:16 | data1 | swap2.cpp:137:15:137:20 | call to source |
3143
| taint.cpp:8:8:8:13 | clean1 | taint.cpp:4:27:4:33 | source1 |
3244
| taint.cpp:16:8:16:14 | source1 | taint.cpp:12:22:12:27 | call to source |
3345
| taint.cpp:17:8:17:16 | ++ ... | taint.cpp:12:22:12:27 | call to source |

0 commit comments

Comments
 (0)