Skip to content

Commit 675a072

Browse files
committed
C++: Add 'pthread_create' test with missing flow.
1 parent 5722084 commit 675a072

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

cpp/ql/test/library-tests/dataflow/external-models/sinks.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
| test.cpp:29:10:29:11 | y3 | test-sink |
99
| test.cpp:33:10:33:11 | z2 | test-sink |
1010
| test.cpp:36:10:36:11 | z3 | test-sink |
11+
| test.cpp:48:14:48:14 | x | test-sink |

cpp/ql/test/library-tests/dataflow/external-models/sources.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| asio_streams.cpp:87:34:87:44 | read_until output argument | remote |
22
| test.cpp:10:10:10:18 | call to ymlSource | local |
3+
| test.cpp:56:8:56:16 | call to ymlSource | local |
34
| windows.cpp:22:15:22:29 | *call to GetCommandLineA | local |
45
| windows.cpp:34:17:34:38 | *call to GetEnvironmentStringsA | local |
56
| windows.cpp:39:36:39:38 | GetEnvironmentVariableA output argument | local |

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,26 @@ void test() {
3535
int z3 = ymlStepGenerated_with_body(x, 0);
3636
ymlSink(z3); // clean
3737
}
38+
39+
struct S {
40+
int x;
41+
};
42+
43+
using pthread_t = unsigned long;
44+
using pthread_attr_t = void*;
45+
46+
void *myThreadFunction(void *arg) {
47+
S* s = (S *)arg;
48+
ymlSink(s->x); // $ MISSING: ir
49+
return nullptr;
50+
}
51+
52+
int pthread_create(pthread_t *thread, const pthread_attr_t * attr, void *(*start_routine)(void*), void *arg);
53+
54+
int test_pthread_create() {
55+
S s;
56+
s.x = ymlSource();
57+
58+
pthread_t threadId;
59+
pthread_create(&threadId, nullptr, myThreadFunction, (void *)&s);
60+
}

0 commit comments

Comments
 (0)