Skip to content

Commit 761e318

Browse files
authored
Merge pull request github#3426 from MathiasVP/test-3110
C++: Add testcase for github#3110
2 parents 2502d1c + 594f3b1 commit 761e318

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ edges
225225
| simple.cpp:65:5:65:22 | ... = ... | simple.cpp:65:5:65:5 | a [post update] [i] |
226226
| simple.cpp:65:11:65:20 | call to user_input | simple.cpp:65:5:65:22 | ... = ... |
227227
| simple.cpp:67:10:67:11 | a2 [i] | simple.cpp:67:13:67:13 | i |
228+
| simple.cpp:83:9:83:10 | f2 [post update] [f1] | simple.cpp:83:9:83:10 | this [post update] [f2, f1] |
229+
| simple.cpp:83:9:83:10 | this [post update] [f2, f1] | simple.cpp:84:14:84:20 | this [f2, f1] |
230+
| simple.cpp:83:9:83:28 | ... = ... | simple.cpp:83:9:83:10 | f2 [post update] [f1] |
231+
| simple.cpp:83:17:83:26 | call to user_input | simple.cpp:83:9:83:28 | ... = ... |
232+
| simple.cpp:84:14:84:20 | this [f2, f1] | simple.cpp:84:14:84:20 | call to getf2f1 |
228233
| struct_init.c:14:24:14:25 | ab [a] | struct_init.c:15:8:15:9 | ab [a] |
229234
| struct_init.c:15:8:15:9 | ab [a] | struct_init.c:15:12:15:12 | a |
230235
| struct_init.c:20:17:20:36 | {...} [a] | struct_init.c:22:8:22:9 | ab [a] |
@@ -513,6 +518,12 @@ nodes
513518
| simple.cpp:65:11:65:20 | call to user_input | semmle.label | call to user_input |
514519
| simple.cpp:67:10:67:11 | a2 [i] | semmle.label | a2 [i] |
515520
| simple.cpp:67:13:67:13 | i | semmle.label | i |
521+
| simple.cpp:83:9:83:10 | f2 [post update] [f1] | semmle.label | f2 [post update] [f1] |
522+
| simple.cpp:83:9:83:10 | this [post update] [f2, f1] | semmle.label | this [post update] [f2, f1] |
523+
| simple.cpp:83:9:83:28 | ... = ... | semmle.label | ... = ... |
524+
| simple.cpp:83:17:83:26 | call to user_input | semmle.label | call to user_input |
525+
| simple.cpp:84:14:84:20 | call to getf2f1 | semmle.label | call to getf2f1 |
526+
| simple.cpp:84:14:84:20 | this [f2, f1] | semmle.label | this [f2, f1] |
516527
| struct_init.c:14:24:14:25 | ab [a] | semmle.label | ab [a] |
517528
| struct_init.c:15:8:15:9 | ab [a] | semmle.label | ab [a] |
518529
| struct_init.c:15:12:15:12 | a | semmle.label | a |
@@ -590,6 +601,7 @@ nodes
590601
| simple.cpp:29:12:29:12 | call to b | simple.cpp:40:12:40:21 | call to user_input | simple.cpp:29:12:29:12 | call to b | call to b flows from $@ | simple.cpp:40:12:40:21 | call to user_input | call to user_input |
591602
| simple.cpp:29:12:29:12 | call to b | simple.cpp:42:12:42:21 | call to user_input | simple.cpp:29:12:29:12 | call to b | call to b flows from $@ | simple.cpp:42:12:42:21 | call to user_input | call to user_input |
592603
| simple.cpp:67:13:67:13 | i | simple.cpp:65:11:65:20 | call to user_input | simple.cpp:67:13:67:13 | i | i flows from $@ | simple.cpp:65:11:65:20 | call to user_input | call to user_input |
604+
| simple.cpp:84:14:84:20 | call to getf2f1 | simple.cpp:83:17:83:26 | call to user_input | simple.cpp:84:14:84:20 | call to getf2f1 | call to getf2f1 flows from $@ | simple.cpp:83:17:83:26 | call to user_input | call to user_input |
593605
| struct_init.c:15:12:15:12 | a | struct_init.c:20:20:20:29 | call to user_input | struct_init.c:15:12:15:12 | a | a flows from $@ | struct_init.c:20:20:20:29 | call to user_input | call to user_input |
594606
| struct_init.c:15:12:15:12 | a | struct_init.c:27:7:27:16 | call to user_input | struct_init.c:15:12:15:12 | a | a flows from $@ | struct_init.c:27:7:27:16 | call to user_input | call to user_input |
595607
| struct_init.c:15:12:15:12 | a | struct_init.c:40:20:40:29 | call to user_input | struct_init.c:15:12:15:12 | a | a flows from $@ | struct_init.c:40:20:40:29 | call to user_input | call to user_input |

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,22 @@ void single_field_test()
6767
sink(a2.i);
6868
}
6969

70+
struct C {
71+
int f1;
72+
};
73+
74+
struct C2
75+
{
76+
C f2;
77+
78+
int getf2f1() {
79+
return f2.f1;
80+
}
81+
82+
void m() {
83+
f2.f1 = user_input();
84+
sink(getf2f1()); // flow
85+
}
86+
};
87+
7088
} // namespace Simple

0 commit comments

Comments
 (0)