Skip to content

Commit 795a2e1

Browse files
authored
Merge pull request #18923 from jketema/template-arguments
C++: Update template test to also output the value of template arguments
2 parents 7a78766 + 324499e commit 795a2e1

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
| test.cpp:3:8:3:8 | C<1> | 0 | int | test.cpp:5:25:5:25 | 1 |
2-
| test.cpp:3:8:3:8 | C<2> | 0 | int | file://:0:0:0:0 | 2 |
3-
| test.cpp:3:8:3:8 | C<x> | 0 | int | file://:0:0:0:0 | x |
4-
| test.cpp:10:8:10:8 | D<T, X> | 0 | <none> | test.cpp:9:19:9:19 | T |
5-
| test.cpp:10:8:10:8 | D<T, X> | 1 | T | file://:0:0:0:0 | X |
6-
| test.cpp:10:8:10:8 | D<int, 2> | 0 | <none> | file://:0:0:0:0 | int |
7-
| test.cpp:10:8:10:8 | D<int, 2> | 1 | int | test.cpp:12:8:12:8 | 2 |
8-
| test.cpp:10:8:10:8 | D<long, 2L> | 0 | <none> | file://:0:0:0:0 | long |
9-
| test.cpp:10:8:10:8 | D<long, 2L> | 1 | long | file://:0:0:0:0 | 2 |
10-
| test.cpp:16:8:16:8 | E<T, X> | 0 | <none> | test.cpp:15:19:15:19 | T |
11-
| test.cpp:16:8:16:8 | E<T, X> | 1 | T * | file://:0:0:0:0 | X |
12-
| test.cpp:16:8:16:8 | E<int, (int *)nullptr> | 0 | <none> | file://:0:0:0:0 | int |
13-
| test.cpp:16:8:16:8 | E<int, (int *)nullptr> | 1 | int * | file://:0:0:0:0 | 0 |
1+
| test.cpp:3:8:3:8 | C<1> | 0 | int | test.cpp:5:25:5:25 | 1 | 1 |
2+
| test.cpp:3:8:3:8 | C<2> | 0 | int | file://:0:0:0:0 | 2 | 2 |
3+
| test.cpp:3:8:3:8 | C<x> | 0 | int | file://:0:0:0:0 | x | x |
4+
| test.cpp:10:8:10:8 | D<T, X> | 0 | <none> | test.cpp:9:19:9:19 | T | <none> |
5+
| test.cpp:10:8:10:8 | D<T, X> | 1 | T | file://:0:0:0:0 | X | X |
6+
| test.cpp:10:8:10:8 | D<int, 2> | 0 | <none> | file://:0:0:0:0 | int | <none> |
7+
| test.cpp:10:8:10:8 | D<int, 2> | 1 | int | test.cpp:12:8:12:8 | 2 | 2 |
8+
| test.cpp:10:8:10:8 | D<long, 2L> | 0 | <none> | file://:0:0:0:0 | long | <none> |
9+
| test.cpp:10:8:10:8 | D<long, 2L> | 1 | long | file://:0:0:0:0 | 2 | 2 |
10+
| test.cpp:16:8:16:8 | E<T, X> | 0 | <none> | test.cpp:15:19:15:19 | T | <none> |
11+
| test.cpp:16:8:16:8 | E<T, X> | 1 | T * | file://:0:0:0:0 | X | X |
12+
| test.cpp:16:8:16:8 | E<int, (int *)nullptr> | 0 | <none> | file://:0:0:0:0 | int | <none> |
13+
| test.cpp:16:8:16:8 | E<int, (int *)nullptr> | 1 | int * | file://:0:0:0:0 | 0 | 0 |

cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.ql

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ string maybeGetTemplateArgumentKind(Declaration d, int i) {
99
i = [0 .. d.getNumberOfTemplateArguments()]
1010
}
1111

12+
string maybeGetTemplateArgumentValue(Declaration d, int i) {
13+
(
14+
if exists(d.getTemplateArgument(i).(Expr).getValue())
15+
then result = d.getTemplateArgument(i).(Expr).getValue()
16+
else result = "<none>"
17+
) and
18+
i = [0 .. d.getNumberOfTemplateArguments()]
19+
}
20+
1221
from Declaration d, int i
1322
where i >= 0 and i < d.getNumberOfTemplateArguments()
14-
select d, i, maybeGetTemplateArgumentKind(d, i), d.getTemplateArgument(i)
23+
select d, i, maybeGetTemplateArgumentKind(d, i), d.getTemplateArgument(i),
24+
maybeGetTemplateArgumentValue(d, i)

0 commit comments

Comments
 (0)