Skip to content

Commit 1ac75de

Browse files
committed
C++: Add another testcase with spurious summary flow.
1 parent 73d0b7e commit 1ac75de

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ reverseRead
2020
argHasPostUpdate
2121
postWithInFlow
2222
| flowOut.cpp:84:3:84:14 | *access to array | PostUpdateNode should not be the target of local flow. |
23+
| flowOut.cpp:111:28:111:31 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
2324
| test.cpp:384:10:384:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
2425
| test.cpp:391:10:391:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
2526
| test.cpp:400:10:400:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,18 @@ void test2() {
101101
addtaint2(&p);
102102
sink(*p); // $ ir MISSING: ast
103103
}
104+
105+
using size_t = decltype(sizeof(int));
106+
107+
void* memcpy(void* dest, const void* src, size_t);
108+
109+
void modify_copy_via_memcpy(char* p) { // $ ast-def=p
110+
char* dest;
111+
char* p2 = (char*)memcpy(dest, p, 10);
112+
source_ref(p2);
113+
}
114+
115+
void test_modify_copy_via_memcpy(char* p) { // $ ast-def=p
116+
modify_copy_via_memcpy(p);
117+
sink(*p); // $ SPURIOUS: ir
118+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ irFlow
175175
| flowOut.cpp:5:16:5:21 | call to source | flowOut.cpp:31:9:31:9 | x |
176176
| flowOut.cpp:5:16:5:21 | call to source | flowOut.cpp:61:8:61:11 | access to array |
177177
| flowOut.cpp:8:16:8:23 | call to source | flowOut.cpp:73:8:73:9 | * ... |
178+
| flowOut.cpp:8:16:8:23 | call to source | flowOut.cpp:117:8:117:9 | * ... |
178179
| flowOut.cpp:84:18:84:23 | call to source | flowOut.cpp:85:8:85:9 | * ... |
179180
| flowOut.cpp:90:8:90:13 | call to source | flowOut.cpp:102:8:102:9 | * ... |
180181
| globals.cpp:5:17:5:22 | call to source | globals.cpp:6:10:6:14 | local |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
| flowOut.cpp:44:7:44:7 | x | flowOut.cpp:46:8:46:8 | x |
33
| flowOut.cpp:59:7:59:7 | x | flowOut.cpp:60:18:60:18 | x |
44
| flowOut.cpp:59:7:59:7 | x | flowOut.cpp:61:8:61:8 | x |
5+
| flowOut.cpp:110:9:110:12 | dest | flowOut.cpp:111:28:111:31 | dest |
56
| ref.cpp:53:9:53:10 | x1 | ref.cpp:55:19:55:20 | x1 |
67
| ref.cpp:53:9:53:10 | x1 | ref.cpp:56:10:56:11 | x1 |
78
| ref.cpp:53:13:53:14 | x2 | ref.cpp:58:15:58:16 | x2 |

0 commit comments

Comments
 (0)