From faa55f50e7c9d454251801bf2ce5f376a1cf09c3 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Tue, 25 Nov 2025 14:52:26 +0000 Subject: [PATCH] C++: Add another test with a template function whose non-type template parameter is in tail position. --- .../dataflow/external-models/flow.expected | 39 ++++++++++++------- .../dataflow/external-models/sinks.expected | 3 +- .../dataflow/external-models/sources.expected | 2 +- .../dataflow/external-models/test.cpp | 12 ++++-- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/cpp/ql/test/library-tests/dataflow/external-models/flow.expected b/cpp/ql/test/library-tests/dataflow/external-models/flow.expected index 95b4e2ef8b4..a6b2c9d5e3a 100644 --- a/cpp/ql/test/library-tests/dataflow/external-models/flow.expected +++ b/cpp/ql/test/library-tests/dataflow/external-models/flow.expected @@ -105,12 +105,18 @@ edges | test.cpp:103:63:103:63 | x | test.cpp:63:6:63:21 | [summary param] 1 in callWithArgument | provenance | | | test.cpp:104:62:104:62 | x | test.cpp:63:6:63:21 | [summary param] 1 in callWithArgument | provenance | | | test.cpp:108:3:108:25 | [summary param] *0 in callWithNonTypeTemplate | test.cpp:108:3:108:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | provenance | MaD:32 | -| test.cpp:111:10:111:18 | call to ymlSource | test.cpp:111:10:111:18 | call to ymlSource | provenance | Src:MaD:16 | -| test.cpp:111:10:111:18 | call to ymlSource | test.cpp:112:43:112:43 | *x | provenance | | -| test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | provenance | | -| test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | test.cpp:113:10:113:10 | y | provenance | Sink:MaD:1 | -| test.cpp:112:43:112:43 | *x | test.cpp:108:3:108:25 | [summary param] *0 in callWithNonTypeTemplate | provenance | | -| test.cpp:112:43:112:43 | *x | test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | provenance | MaD:32 | +| test.cpp:111:3:111:25 | [summary param] *0 in callWithNonTypeTemplate | test.cpp:111:3:111:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | provenance | MaD:32 | +| test.cpp:114:10:114:18 | call to ymlSource | test.cpp:114:10:114:18 | call to ymlSource | provenance | Src:MaD:16 | +| test.cpp:114:10:114:18 | call to ymlSource | test.cpp:115:44:115:44 | *x | provenance | | +| test.cpp:114:10:114:18 | call to ymlSource | test.cpp:118:44:118:44 | *x | provenance | | +| test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | provenance | | +| test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | test.cpp:116:10:116:11 | y1 | provenance | Sink:MaD:1 | +| test.cpp:115:44:115:44 | *x | test.cpp:108:3:108:25 | [summary param] *0 in callWithNonTypeTemplate | provenance | | +| test.cpp:115:44:115:44 | *x | test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | provenance | MaD:32 | +| test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | provenance | | +| test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | test.cpp:119:10:119:11 | y2 | provenance | Sink:MaD:1 | +| test.cpp:118:44:118:44 | *x | test.cpp:111:3:111:25 | [summary param] *0 in callWithNonTypeTemplate | provenance | | +| test.cpp:118:44:118:44 | *x | test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | provenance | MaD:32 | | windows.cpp:17:8:17:25 | [summary param] *0 in CommandLineToArgvA | windows.cpp:17:8:17:25 | [summary] to write: ReturnValue[**] in CommandLineToArgvA | provenance | MaD:18 | | windows.cpp:22:15:22:29 | *call to GetCommandLineA | windows.cpp:22:15:22:29 | *call to GetCommandLineA | provenance | Src:MaD:3 | | windows.cpp:22:15:22:29 | *call to GetCommandLineA | windows.cpp:24:8:24:11 | * ... | provenance | | @@ -324,12 +330,18 @@ nodes | test.cpp:104:62:104:62 | x | semmle.label | x | | test.cpp:108:3:108:25 | [summary param] *0 in callWithNonTypeTemplate | semmle.label | [summary param] *0 in callWithNonTypeTemplate | | test.cpp:108:3:108:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | semmle.label | [summary] to write: ReturnValue in callWithNonTypeTemplate | -| test.cpp:111:10:111:18 | call to ymlSource | semmle.label | call to ymlSource | -| test.cpp:111:10:111:18 | call to ymlSource | semmle.label | call to ymlSource | -| test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | semmle.label | call to callWithNonTypeTemplate | -| test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | semmle.label | call to callWithNonTypeTemplate | -| test.cpp:112:43:112:43 | *x | semmle.label | *x | -| test.cpp:113:10:113:10 | y | semmle.label | y | +| test.cpp:111:3:111:25 | [summary param] *0 in callWithNonTypeTemplate | semmle.label | [summary param] *0 in callWithNonTypeTemplate | +| test.cpp:111:3:111:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | semmle.label | [summary] to write: ReturnValue in callWithNonTypeTemplate | +| test.cpp:114:10:114:18 | call to ymlSource | semmle.label | call to ymlSource | +| test.cpp:114:10:114:18 | call to ymlSource | semmle.label | call to ymlSource | +| test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | semmle.label | call to callWithNonTypeTemplate | +| test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | semmle.label | call to callWithNonTypeTemplate | +| test.cpp:115:44:115:44 | *x | semmle.label | *x | +| test.cpp:116:10:116:11 | y1 | semmle.label | y1 | +| test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | semmle.label | call to callWithNonTypeTemplate | +| test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | semmle.label | call to callWithNonTypeTemplate | +| test.cpp:118:44:118:44 | *x | semmle.label | *x | +| test.cpp:119:10:119:11 | y2 | semmle.label | y2 | | windows.cpp:17:8:17:25 | [summary param] *0 in CommandLineToArgvA | semmle.label | [summary param] *0 in CommandLineToArgvA | | windows.cpp:17:8:17:25 | [summary] to write: ReturnValue[**] in CommandLineToArgvA | semmle.label | [summary] to write: ReturnValue[**] in CommandLineToArgvA | | windows.cpp:22:15:22:29 | *call to GetCommandLineA | semmle.label | *call to GetCommandLineA | @@ -488,7 +500,8 @@ subpaths | test.cpp:21:27:21:27 | x | test.cpp:5:5:5:20 | [summary param] 0 in ymlStepGenerated | test.cpp:5:5:5:20 | [summary] to write: ReturnValue in ymlStepGenerated | test.cpp:21:10:21:25 | call to ymlStepGenerated | | test.cpp:25:35:25:35 | x | test.cpp:6:5:6:27 | [summary param] 0 in ymlStepManual_with_body | test.cpp:6:5:6:27 | [summary] to write: ReturnValue in ymlStepManual_with_body | test.cpp:25:11:25:33 | call to ymlStepManual_with_body | | test.cpp:32:41:32:41 | x | test.cpp:7:47:7:52 | value2 | test.cpp:7:5:7:30 | *ymlStepGenerated_with_body | test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body | -| test.cpp:112:43:112:43 | *x | test.cpp:108:3:108:25 | [summary param] *0 in callWithNonTypeTemplate | test.cpp:108:3:108:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | test.cpp:112:10:112:41 | call to callWithNonTypeTemplate | +| test.cpp:115:44:115:44 | *x | test.cpp:108:3:108:25 | [summary param] *0 in callWithNonTypeTemplate | test.cpp:108:3:108:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | test.cpp:115:11:115:42 | call to callWithNonTypeTemplate | +| test.cpp:118:44:118:44 | *x | test.cpp:111:3:111:25 | [summary param] *0 in callWithNonTypeTemplate | test.cpp:111:3:111:25 | [summary] to write: ReturnValue in callWithNonTypeTemplate | test.cpp:118:11:118:42 | call to callWithNonTypeTemplate | | windows.cpp:27:36:27:38 | *cmd | windows.cpp:17:8:17:25 | [summary param] *0 in CommandLineToArgvA | windows.cpp:17:8:17:25 | [summary] to write: ReturnValue[**] in CommandLineToArgvA | windows.cpp:27:17:27:34 | **call to CommandLineToArgvA | | windows.cpp:537:40:537:41 | *& ... | windows.cpp:473:17:473:37 | [summary param] *1 in RtlCopyVolatileMemory | windows.cpp:473:17:473:37 | [summary param] *0 in RtlCopyVolatileMemory [Return] | windows.cpp:537:27:537:37 | RtlCopyVolatileMemory output argument | | windows.cpp:542:38:542:39 | *& ... | windows.cpp:479:17:479:35 | [summary param] *1 in RtlCopyDeviceMemory | windows.cpp:479:17:479:35 | [summary param] *0 in RtlCopyDeviceMemory [Return] | windows.cpp:542:25:542:35 | RtlCopyDeviceMemory output argument | diff --git a/cpp/ql/test/library-tests/dataflow/external-models/sinks.expected b/cpp/ql/test/library-tests/dataflow/external-models/sinks.expected index 51c2180f113..e28349b7159 100644 --- a/cpp/ql/test/library-tests/dataflow/external-models/sinks.expected +++ b/cpp/ql/test/library-tests/dataflow/external-models/sinks.expected @@ -13,4 +13,5 @@ | test.cpp:75:11:75:11 | y | test-sink | | test.cpp:83:11:83:11 | y | test-sink | | test.cpp:89:11:89:11 | y | test-sink | -| test.cpp:113:10:113:10 | y | test-sink | +| test.cpp:116:10:116:11 | y1 | test-sink | +| test.cpp:119:10:119:11 | y2 | test-sink | diff --git a/cpp/ql/test/library-tests/dataflow/external-models/sources.expected b/cpp/ql/test/library-tests/dataflow/external-models/sources.expected index fc975299737..cb7e06b801d 100644 --- a/cpp/ql/test/library-tests/dataflow/external-models/sources.expected +++ b/cpp/ql/test/library-tests/dataflow/external-models/sources.expected @@ -2,7 +2,7 @@ | test.cpp:10:10:10:18 | call to ymlSource | local | | test.cpp:56:8:56:16 | call to ymlSource | local | | test.cpp:94:10:94:18 | call to ymlSource | local | -| test.cpp:111:10:111:18 | call to ymlSource | local | +| test.cpp:114:10:114:18 | call to ymlSource | local | | windows.cpp:22:15:22:29 | *call to GetCommandLineA | local | | windows.cpp:34:17:34:38 | *call to GetEnvironmentStringsA | local | | windows.cpp:39:36:39:38 | GetEnvironmentVariableA output argument | local | diff --git a/cpp/ql/test/library-tests/dataflow/external-models/test.cpp b/cpp/ql/test/library-tests/dataflow/external-models/test.cpp index ce5179e3157..6a021431bd9 100644 --- a/cpp/ql/test/library-tests/dataflow/external-models/test.cpp +++ b/cpp/ql/test/library-tests/dataflow/external-models/test.cpp @@ -107,8 +107,14 @@ void test_callWithArgument() { template T callWithNonTypeTemplate(const T&); +template +T callWithNonTypeTemplate(const T&); + void test_callWithNonTypeTemplate() { int x = ymlSource(); - int y = callWithNonTypeTemplate<10, int>(x); - ymlSink(y); // $ ir -} \ No newline at end of file + int y1 = callWithNonTypeTemplate<10, int>(x); + ymlSink(y1); // $ ir + + int y2 = callWithNonTypeTemplate(x); + ymlSink(y2); // $ ir +}