From 60f3598da9518906c57cc22982f7eb920e619a23 Mon Sep 17 00:00:00 2001 From: Alex Eyers-Taylor Date: Fri, 27 Oct 2023 18:17:01 +0100 Subject: [PATCH] CPP: Add dataflow FP with output arguments --- .../dataflow-consistency.expected | 3 +++ .../dataflow/dataflow-tests/flowOut.cpp | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 cpp/ql/test/library-tests/dataflow/dataflow-tests/flowOut.cpp diff --git a/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected b/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected index e5c884beb22..01fc86f1a38 100644 --- a/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected +++ b/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected @@ -41,6 +41,9 @@ postWithInFlow | example.c:26:9:26:9 | x [post update] | PostUpdateNode should not be the target of local flow. | | example.c:26:19:26:24 | coords [inner post update] | PostUpdateNode should not be the target of local flow. | | example.c:28:23:28:25 | pos [inner post update] | PostUpdateNode should not be the target of local flow. | +| flowOut.cpp:5:5:5:12 | * ... [post update] | PostUpdateNode should not be the target of local flow. | +| flowOut.cpp:5:6:5:12 | toTaint [inner post update] | PostUpdateNode should not be the target of local flow. | +| flowOut.cpp:18:17:18:17 | x [inner post update] | PostUpdateNode should not be the target of local flow. | | globals.cpp:13:5:13:19 | flowTestGlobal1 [post update] | PostUpdateNode should not be the target of local flow. | | globals.cpp:23:5:23:19 | flowTestGlobal2 [post update] | PostUpdateNode should not be the target of local flow. | | lambdas.cpp:23:3:23:14 | v [post update] | PostUpdateNode should not be the target of local flow. | diff --git a/cpp/ql/test/library-tests/dataflow/dataflow-tests/flowOut.cpp b/cpp/ql/test/library-tests/dataflow/dataflow-tests/flowOut.cpp new file mode 100644 index 00000000000..6c0a398ea26 --- /dev/null +++ b/cpp/ql/test/library-tests/dataflow/dataflow-tests/flowOut.cpp @@ -0,0 +1,20 @@ +int source(); +void sink(int); + +void source_ref(int *toTaint) { // $ ir-def=*toTaint ast-def=toTaint + *toTaint = source(); +} + + + +void modify_copy(int* ptr) { // $ ast-def=ptr + int deref = *ptr; + int* other = &deref; + source_ref(other); +} + +void test_output() { + int x = 0; + modify_copy(&x); + sink(x); // $ ir +} \ No newline at end of file