Skip to content

Commit 4a7ad84

Browse files
committed
C++: Add __func__ and __PRETTY_FUNCTION__ IR tests
1 parent 584a018 commit 4a7ad84

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

cpp/ql/test/library-tests/ir/ir/PrintAST.expected

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14137,6 +14137,30 @@ ir.cpp:
1413714137
# 1845| Type = [Struct] B
1413814138
# 1845| ValueCategory = lvalue
1413914139
# 1846| getStmt(2): [ReturnStmt] return ...
14140+
# 1849| [TopLevelFunction] void magicvars()
14141+
# 1849| <params>:
14142+
# 1849| getEntryPoint(): [BlockStmt] { ... }
14143+
# 1850| getStmt(0): [DeclStmt] declaration
14144+
# 1850| getDeclarationEntry(0): [VariableDeclarationEntry] definition of pf
14145+
# 1850| Type = [PointerType] const char *
14146+
# 1850| getVariable().getInitializer(): [Initializer] initializer for pf
14147+
# 1850| getExpr(): [VariableAccess] __PRETTY_FUNCTION__
14148+
# 1850| Type = [ArrayType] const char[17]
14149+
# 1850| ValueCategory = lvalue
14150+
# 1850| getExpr().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion
14151+
# 1850| Type = [PointerType] const char *
14152+
# 1850| ValueCategory = prvalue
14153+
# 1851| getStmt(1): [DeclStmt] declaration
14154+
# 1851| getDeclarationEntry(0): [VariableDeclarationEntry] definition of strfunc
14155+
# 1851| Type = [PointerType] const char *
14156+
# 1851| getVariable().getInitializer(): [Initializer] initializer for strfunc
14157+
# 1851| getExpr(): [VariableAccess] __func__
14158+
# 1851| Type = [ArrayType] const char[10]
14159+
# 1851| ValueCategory = lvalue
14160+
# 1851| getExpr().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion
14161+
# 1851| Type = [PointerType] const char *
14162+
# 1851| ValueCategory = prvalue
14163+
# 1852| getStmt(2): [ReturnStmt] return ...
1414014164
perf-regression.cpp:
1414114165
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1414214166
# 4| <params>:

cpp/ql/test/library-tests/ir/ir/ir.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,4 +1846,9 @@ namespace block_assignment {
18461846
}
18471847
}
18481848

1849+
void magicvars() {
1850+
const char *pf = __PRETTY_FUNCTION__;
1851+
const char *strfunc = __func__;
1852+
}
1853+
18491854
// semmle-extractor-options: -std=c++17 --clang

cpp/ql/test/library-tests/ir/ir/operand_locations.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8641,6 +8641,15 @@
86418641
| ir.cpp:1845:13:1845:13 | SideEffect | ~m1845_9 |
86428642
| ir.cpp:1845:13:1845:13 | SideEffect | ~m1845_12 |
86438643
| ir.cpp:1845:13:1845:13 | Unary | r1845_3 |
8644+
| ir.cpp:1849:6:1849:14 | ChiPartial | partial:m1849_3 |
8645+
| ir.cpp:1849:6:1849:14 | ChiTotal | total:m1849_2 |
8646+
| ir.cpp:1849:6:1849:14 | SideEffect | m1849_3 |
8647+
| ir.cpp:1850:17:1850:18 | Address | &:r1850_1 |
8648+
| ir.cpp:1850:22:1850:40 | StoreValue | r1850_3 |
8649+
| ir.cpp:1850:22:1850:40 | Unary | r1850_2 |
8650+
| ir.cpp:1851:17:1851:23 | Address | &:r1851_1 |
8651+
| ir.cpp:1851:27:1851:34 | StoreValue | r1851_3 |
8652+
| ir.cpp:1851:27:1851:34 | Unary | r1851_2 |
86448653
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
86458654
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
86468655
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9914,6 +9914,24 @@ ir.cpp:
99149914
# 1843| v1843_5(void) = AliasedUse : ~m?
99159915
# 1843| v1843_6(void) = ExitFunction :
99169916

9917+
# 1849| void magicvars()
9918+
# 1849| Block 0
9919+
# 1849| v1849_1(void) = EnterFunction :
9920+
# 1849| mu1849_2(unknown) = AliasedDefinition :
9921+
# 1849| mu1849_3(unknown) = InitializeNonLocal :
9922+
# 1850| r1850_1(glval<char *>) = VariableAddress[pf] :
9923+
# 1850| r1850_2(glval<char[17]>) = VariableAddress[__PRETTY_FUNCTION__] :
9924+
# 1850| r1850_3(char *) = Convert : r1850_2
9925+
# 1850| mu1850_4(char *) = Store[pf] : &:r1850_1, r1850_3
9926+
# 1851| r1851_1(glval<char *>) = VariableAddress[strfunc] :
9927+
# 1851| r1851_2(glval<char[10]>) = VariableAddress[__func__] :
9928+
# 1851| r1851_3(char *) = Convert : r1851_2
9929+
# 1851| mu1851_4(char *) = Store[strfunc] : &:r1851_1, r1851_3
9930+
# 1852| v1852_1(void) = NoOp :
9931+
# 1849| v1849_4(void) = ReturnVoid :
9932+
# 1849| v1849_5(void) = AliasedUse : ~m?
9933+
# 1849| v1849_6(void) = ExitFunction :
9934+
99179935
perf-regression.cpp:
99189936
# 6| void Big::Big()
99199937
# 6| Block 0

0 commit comments

Comments
 (0)