From 0f2731064d3fd0c46023dd1c75f39c3a85cefd30 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 18 Sep 2019 14:23:52 +0200 Subject: [PATCH] C++: Annotate `tellDifferent` with template status This is helpful for turning real-world cases into test cases. --- .../library-tests/syntax-zoo/tellDifferent.expected | 6 +++--- cpp/ql/test/library-tests/syntax-zoo/tellDifferent.ql | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.expected b/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.expected index ffb4863ef4c..0e06bb202c4 100644 --- a/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.expected +++ b/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.expected @@ -1,3 +1,3 @@ -| staticlocals__staticlocals_f2 | file://:0:0:0:0 | call to C | staticlocals.cpp:30:1:30:1 | return ... | Standard edge, only from QL | -| staticlocals__staticlocals_f2 | file://:0:0:0:0 | initializer for c | file://:0:0:0:0 | call to C | Standard edge, only from QL | -| staticlocals__staticlocals_f2 | staticlocals.cpp:29:5:29:17 | declaration | file://:0:0:0:0 | initializer for c | Standard edge, only from QL | +| staticlocals__staticlocals_f2 | file://:0:0:0:0 | call to C | staticlocals.cpp:30:1:30:1 | return ... | Standard edge, only from QL | | +| staticlocals__staticlocals_f2 | file://:0:0:0:0 | initializer for c | file://:0:0:0:0 | call to C | Standard edge, only from QL | | +| staticlocals__staticlocals_f2 | staticlocals.cpp:29:5:29:17 | declaration | file://:0:0:0:0 | initializer for c | Standard edge, only from QL | | diff --git a/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.ql b/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.ql index e1bd8c99b78..f4b2509c17b 100644 --- a/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.ql +++ b/cpp/ql/test/library-tests/syntax-zoo/tellDifferent.ql @@ -1,5 +1,13 @@ import Compare +string describeTemplate(ControlFlowNode node) { + node.isFromTemplateInstantiation(_) and + result = "instantiation" + or + node.isFromUninstantiatedTemplate(_) and + result = "uninstantiated" +} + from ControlFlowNode n1, ControlFlowNode n2, string msg where differentEdge(n1, n2, msg) -select getScopeName(n1), n1, n2, msg +select getScopeName(n1), n1, n2, msg, concat(describeTemplate(n1), ", ")