File tree Expand file tree Collapse file tree
cpp/ql/test/library-tests/dataflow/fields Expand file tree Collapse file tree Original file line number Diff line number Diff line change 320320| simple.cpp:83:9:83:10 | this | AST only |
321321| simple.cpp:83:12:83:13 | f1 | AST only |
322322| simple.cpp:84:14:84:20 | this | AST only |
323+ | simple.cpp:105:5:105:6 | d2 | AST only |
324+ | simple.cpp:105:14:105:14 | y | AST only |
325+ | simple.cpp:122:5:122:6 | d3 | AST only |
326+ | simple.cpp:122:8:122:11 | d2_1 | AST only |
327+ | simple.cpp:122:18:122:18 | x | AST only |
328+ | simple.cpp:136:21:136:28 | & ... | AST only |
329+ | simple.cpp:136:22:136:23 | d3 | AST only |
330+ | simple.cpp:143:23:143:30 | & ... | AST only |
331+ | simple.cpp:143:24:143:25 | d3 | AST only |
332+ | simple.cpp:144:23:144:30 | & ... | AST only |
333+ | simple.cpp:144:24:144:25 | d3 | AST only |
323334| struct_init.c:15:8:15:9 | ab | AST only |
324335| struct_init.c:15:12:15:12 | a | AST only |
325336| struct_init.c:16:8:16:9 | ab | AST only |
Original file line number Diff line number Diff line change 4141| simple.cpp:21:24:21:25 | this |
4242| simple.cpp:65:5:65:5 | a |
4343| simple.cpp:83:9:83:10 | f2 |
44+ | simple.cpp:105:9:105:12 | d1_2 |
45+ | simple.cpp:122:13:122:16 | d1_1 |
Original file line number Diff line number Diff line change 363363| simple.cpp:83:9:83:10 | this |
364364| simple.cpp:83:12:83:13 | f1 |
365365| simple.cpp:84:14:84:20 | this |
366+ | simple.cpp:105:5:105:6 | d2 |
367+ | simple.cpp:105:9:105:12 | d1_2 |
368+ | simple.cpp:105:14:105:14 | y |
369+ | simple.cpp:122:5:122:6 | d3 |
370+ | simple.cpp:122:8:122:11 | d2_1 |
371+ | simple.cpp:122:13:122:16 | d1_1 |
372+ | simple.cpp:122:18:122:18 | x |
373+ | simple.cpp:136:21:136:28 | & ... |
374+ | simple.cpp:136:22:136:23 | d3 |
375+ | simple.cpp:143:23:143:30 | & ... |
376+ | simple.cpp:143:24:143:25 | d3 |
377+ | simple.cpp:144:23:144:30 | & ... |
378+ | simple.cpp:144:24:144:25 | d3 |
366379| struct_init.c:15:8:15:9 | ab |
367380| struct_init.c:15:12:15:12 | a |
368381| struct_init.c:16:8:16:9 | ab |
Original file line number Diff line number Diff line change @@ -85,4 +85,63 @@ struct C2
8585 }
8686};
8787
88+ struct DeepStruct1 {
89+ int x;
90+ int y;
91+ };
92+
93+ struct DeepStruct2 {
94+ DeepStruct1 d1_1;
95+ DeepStruct1 d1_2;
96+ };
97+
98+ struct DeepStruct3 {
99+ DeepStruct2 d2_1;
100+ DeepStruct2 d2_2;
101+ DeepStruct1 d1_1;
102+ };
103+
104+ void write_to_d1_2_y (DeepStruct2* d2, int val) {
105+ d2->d1_2 .y = val;
106+ }
107+
108+ void read_from_y (DeepStruct2 d2) {
109+ sink (d2.d1_1 .y );
110+ // Hopefully we will catch this flow when we merge #3123
111+ sink (d2.d1_2 .y ); // $ast $f-:ir
112+ }
113+
114+ void read_from_y_deref (DeepStruct2* d2) {
115+ sink (d2->d1_1 .y );
116+ // Hopefully we will catch this flow when we merge #3123
117+ sink (d2->d1_2 .y ); // $ast $f-:ir
118+ }
119+
120+ void test_deep_structs () {
121+ DeepStruct3 d3;
122+ d3.d2_1 .d1_1 .x = user_input ();
123+ DeepStruct2 d2_1 = d3.d2_1 ;
124+ sink (d2_1.d1_1 .x ); // $ast $f-:ir
125+ sink (d2_1.d1_1 .y );
126+
127+ sink (d2_1.d1_2 .x );
128+
129+ DeepStruct1* pd1 = &d2_1.d1_1 ;
130+ sink (pd1->x ); // $ast $f-:ir
131+ }
132+
133+ void test_deep_structs_setter () {
134+ DeepStruct3 d3;
135+
136+ write_to_d1_2_y (&d3.d2_1 , user_input ());
137+
138+ sink (d3.d2_1 .d1_1 .y ); // $f+:ir
139+ sink (d3.d2_1 .d1_2 .y ); // $ast $ir
140+
141+ read_from_y (d3.d2_1 );
142+ read_from_y (d3.d2_2 );
143+ read_from_y_deref (&d3.d2_1 );
144+ read_from_y_deref (&d3.d2_2 );
145+ }
146+
88147} // namespace Simple
You can’t perform that action at this time.
0 commit comments