Skip to content

Commit 259bf27

Browse files
committed
C++: Add pointer/pointee conflation test.
1 parent c9cf2a8 commit 259bf27

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ postWithInFlow
159159
| test.cpp:808:5:808:21 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
160160
| test.cpp:808:6:808:21 | global_indirect1 [inner post update] | PostUpdateNode should not be the target of local flow. |
161161
| test.cpp:832:5:832:17 | global_direct [post update] | PostUpdateNode should not be the target of local flow. |
162+
| test.cpp:931:5:931:18 | global_pointer [post update] | PostUpdateNode should not be the target of local flow. |
163+
| test.cpp:932:5:932:19 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
164+
| test.cpp:932:6:932:19 | global_pointer [inner post update] | PostUpdateNode should not be the target of local flow. |
162165
viableImplInCallContextTooLarge
163166
uniqueParameterNodeAtPosition
164167
uniqueParameterNodePosition

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ uniqueType
44
uniqueNodeLocation
55
missingLocation
66
uniqueNodeToString
7+
| test.cpp:930:8:930:10 | Use of **global_pointer | Node should have one toString but has 2. |
8+
| test.cpp:930:8:930:10 | Use of *global_pointer | Node should have one toString but has 2. |
79
parameterCallable
810
localFlowIsLocal
911
readStepIsLocal

cpp/ql/test/library-tests/dataflow/dataflow-tests/test-source-sink.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ irFlow
300300
| test.cpp:902:56:902:75 | *indirect_source(2) | test.cpp:911:19:911:48 | *global_array_static_indirect_2 |
301301
| test.cpp:914:46:914:53 | source | test.cpp:919:10:919:30 | global_pointer_static |
302302
| test.cpp:915:57:915:76 | *indirect_source(1) | test.cpp:921:19:921:50 | *global_pointer_static_indirect_1 |
303+
| test.cpp:932:23:932:28 | call to source | test.cpp:936:10:936:23 | global_pointer |
304+
| test.cpp:932:23:932:28 | call to source | test.cpp:937:10:937:24 | * ... |
303305
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |
304306
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
305307
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,4 +922,18 @@ namespace GlobalArrays {
922922
sink(global_pointer_static_indirect_2); // clean: global_pointer_static_indirect_2 does not have 2 indirections
923923
indirect_sink(global_pointer_static_indirect_2); // clean: global_pointer_static_indirect_2 does not have 2 indirections
924924
}
925+
}
926+
927+
namespace global_variable_conflation_test {
928+
int* global_pointer;
929+
930+
void def() {
931+
global_pointer = nullptr;
932+
*global_pointer = source();
933+
}
934+
935+
void use() {
936+
sink(global_pointer); // $ SPURIOUS: ir
937+
sink(*global_pointer); // $ ir MISSING: ast
938+
}
925939
}

0 commit comments

Comments
 (0)