mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
C++: Add testcases for partial definitions with long access paths
This commit is contained in:
@@ -320,6 +320,17 @@
|
||||
| simple.cpp:83:9:83:10 | this | AST only |
|
||||
| simple.cpp:83:12:83:13 | f1 | AST only |
|
||||
| simple.cpp:84:14:84:20 | this | AST only |
|
||||
| simple.cpp:105:5:105:6 | d2 | AST only |
|
||||
| simple.cpp:105:14:105:14 | y | AST only |
|
||||
| simple.cpp:122:5:122:6 | d3 | AST only |
|
||||
| simple.cpp:122:8:122:11 | d2_1 | AST only |
|
||||
| simple.cpp:122:18:122:18 | x | AST only |
|
||||
| simple.cpp:136:21:136:28 | & ... | AST only |
|
||||
| simple.cpp:136:22:136:23 | d3 | AST only |
|
||||
| simple.cpp:143:23:143:30 | & ... | AST only |
|
||||
| simple.cpp:143:24:143:25 | d3 | AST only |
|
||||
| simple.cpp:144:23:144:30 | & ... | AST only |
|
||||
| simple.cpp:144:24:144:25 | d3 | AST only |
|
||||
| struct_init.c:15:8:15:9 | ab | AST only |
|
||||
| struct_init.c:15:12:15:12 | a | AST only |
|
||||
| struct_init.c:16:8:16:9 | ab | AST only |
|
||||
|
||||
@@ -41,3 +41,5 @@
|
||||
| simple.cpp:21:24:21:25 | this |
|
||||
| simple.cpp:65:5:65:5 | a |
|
||||
| simple.cpp:83:9:83:10 | f2 |
|
||||
| simple.cpp:105:9:105:12 | d1_2 |
|
||||
| simple.cpp:122:13:122:16 | d1_1 |
|
||||
|
||||
@@ -363,6 +363,19 @@
|
||||
| simple.cpp:83:9:83:10 | this |
|
||||
| simple.cpp:83:12:83:13 | f1 |
|
||||
| simple.cpp:84:14:84:20 | this |
|
||||
| simple.cpp:105:5:105:6 | d2 |
|
||||
| simple.cpp:105:9:105:12 | d1_2 |
|
||||
| simple.cpp:105:14:105:14 | y |
|
||||
| simple.cpp:122:5:122:6 | d3 |
|
||||
| simple.cpp:122:8:122:11 | d2_1 |
|
||||
| simple.cpp:122:13:122:16 | d1_1 |
|
||||
| simple.cpp:122:18:122:18 | x |
|
||||
| simple.cpp:136:21:136:28 | & ... |
|
||||
| simple.cpp:136:22:136:23 | d3 |
|
||||
| simple.cpp:143:23:143:30 | & ... |
|
||||
| simple.cpp:143:24:143:25 | d3 |
|
||||
| simple.cpp:144:23:144:30 | & ... |
|
||||
| simple.cpp:144:24:144:25 | d3 |
|
||||
| struct_init.c:15:8:15:9 | ab |
|
||||
| struct_init.c:15:12:15:12 | a |
|
||||
| struct_init.c:16:8:16:9 | ab |
|
||||
|
||||
@@ -85,4 +85,63 @@ struct C2
|
||||
}
|
||||
};
|
||||
|
||||
struct DeepStruct1 {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct DeepStruct2 {
|
||||
DeepStruct1 d1_1;
|
||||
DeepStruct1 d1_2;
|
||||
};
|
||||
|
||||
struct DeepStruct3 {
|
||||
DeepStruct2 d2_1;
|
||||
DeepStruct2 d2_2;
|
||||
DeepStruct1 d1_1;
|
||||
};
|
||||
|
||||
void write_to_d1_2_y(DeepStruct2* d2, int val) {
|
||||
d2->d1_2.y = val;
|
||||
}
|
||||
|
||||
void read_from_y(DeepStruct2 d2) {
|
||||
sink(d2.d1_1.y);
|
||||
// Hopefully we will catch this flow when we merge #3123
|
||||
sink(d2.d1_2.y); //$ast $f-:ir
|
||||
}
|
||||
|
||||
void read_from_y_deref(DeepStruct2* d2) {
|
||||
sink(d2->d1_1.y);
|
||||
// Hopefully we will catch this flow when we merge #3123
|
||||
sink(d2->d1_2.y); //$ast $f-:ir
|
||||
}
|
||||
|
||||
void test_deep_structs() {
|
||||
DeepStruct3 d3;
|
||||
d3.d2_1.d1_1.x = user_input();
|
||||
DeepStruct2 d2_1 = d3.d2_1;
|
||||
sink(d2_1.d1_1.x); //$ast $f-:ir
|
||||
sink(d2_1.d1_1.y);
|
||||
|
||||
sink(d2_1.d1_2.x);
|
||||
|
||||
DeepStruct1* pd1 = &d2_1.d1_1;
|
||||
sink(pd1->x); //$ast $f-:ir
|
||||
}
|
||||
|
||||
void test_deep_structs_setter() {
|
||||
DeepStruct3 d3;
|
||||
|
||||
write_to_d1_2_y(&d3.d2_1, user_input());
|
||||
|
||||
sink(d3.d2_1.d1_1.y); //$f+:ir
|
||||
sink(d3.d2_1.d1_2.y); //$ast $ir
|
||||
|
||||
read_from_y(d3.d2_1);
|
||||
read_from_y(d3.d2_2);
|
||||
read_from_y_deref(&d3.d2_1);
|
||||
read_from_y_deref(&d3.d2_2);
|
||||
}
|
||||
|
||||
} // namespace Simple
|
||||
|
||||
Reference in New Issue
Block a user