Skip to content

Commit a082172

Browse files
committed
C++: Add testcase demonstrating missing local flow out of fields that are defined by reference.
1 parent d900fca commit a082172

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@
7070
| test.cpp:391:11:391:13 | tmp | test.cpp:391:10:391:13 | & ... |
7171
| test.cpp:391:17:391:23 | source1 | test.cpp:391:10:391:13 | ref arg & ... |
7272
| test.cpp:391:17:391:23 | source1 | test.cpp:391:16:391:23 | & ... |
73+
| test.cpp:480:67:480:67 | s | test.cpp:481:21:481:21 | s |
74+
| test.cpp:480:67:480:67 | s | test.cpp:482:20:482:20 | s |
75+
| test.cpp:481:21:481:21 | s [post update] | test.cpp:482:20:482:20 | s |
76+
| test.cpp:482:23:482:29 | content | test.cpp:483:9:483:17 | p_content |

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,15 @@ void viaOutparam() {
470470
intOutparamSource(&x);
471471
sink(x); // $ ast,ir
472472
}
473+
474+
void writes_to_content(void*);
475+
476+
struct MyStruct {
477+
int* content;
478+
};
479+
480+
void local_field_flow_def_by_ref_steps_with_local_flow(MyStruct * s) {
481+
writes_to_content(s->content);
482+
int* p_content = s->content;
483+
sink(*p_content);
484+
}

0 commit comments

Comments
 (0)