C++: Add some simple non-type template tests

This commit is contained in:
Matthew Gretton-Dann
2019-10-18 15:30:41 +01:00
parent 4ab87291f3
commit 469832668f
6 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
template <int i>
class Int { };
Int<10> i;

View File

@@ -0,0 +1,2 @@
| test.cpp:2:7:2:9 | Int<10> | file://:0:0:0:0 | int | test.cpp:4:5:4:6 | 10 |
| test.cpp:2:7:2:9 | Int<i> | file://:0:0:0:0 | int | file://:0:0:0:0 | Unknown literal |

View File

@@ -0,0 +1,4 @@
import cpp
from Class c
select c, c.getATemplateArgument(), c.getATemplateArgumentValue()

View File

@@ -0,0 +1,5 @@
// semmle-extractor-options: --edg --trap_container=folder --edg --trap-compression=none
template <int i>
int addToSelf() { return i + i; };
int bar() { return addToSelf<10>(); }

View File

@@ -0,0 +1,2 @@
| test.cpp:3:5:3:5 | addToSelf | file://:0:0:0:0 | int | test.cpp:5:30:5:31 | 10 |
| test.cpp:3:5:3:13 | addToSelf | file://:0:0:0:0 | int | file://:0:0:0:0 | Unknown literal |

View File

@@ -0,0 +1,4 @@
import cpp
from Function f
select f, f.getATemplateArgument(), f.getATemplateArgumentValue()