Skip to content

Commit b575747

Browse files
committed
C++: Add testcase with invalid IR.
1 parent da64ea4 commit b575747

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-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
@@ -15716,6 +15716,30 @@ ir.cpp:
1571615716
# 2065| Type = [PointerType] Derived2 *
1571715717
# 2065| ValueCategory = prvalue(load)
1571815718
# 2066| getStmt(6): [ReturnStmt] return ...
15719+
# 2068| [TopLevelFunction] void test_constant_folding_use(int)
15720+
# 2068| <params>:
15721+
# 2068| getParameter(0): [Parameter] (unnamed parameter 0)
15722+
# 2068| Type = [IntType] int
15723+
# 2070| [TopLevelFunction] void test_constant_folding()
15724+
# 2070| <params>:
15725+
# 2070| getEntryPoint(): [BlockStmt] { ... }
15726+
# 2071| getStmt(0): [DeclStmt] declaration
15727+
# 2071| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
15728+
# 2071| Type = [SpecifiedType] const int
15729+
# 2071| getVariable().getInitializer(): [Initializer] initializer for x
15730+
# 2071| getExpr(): [Literal] 116
15731+
# 2071| Type = [IntType] int
15732+
# 2071| Value = [Literal] 116
15733+
# 2071| ValueCategory = prvalue
15734+
# 2072| getStmt(1): [ExprStmt] ExprStmt
15735+
# 2072| getExpr(): [FunctionCall] call to test_constant_folding_use
15736+
# 2072| Type = [VoidType] void
15737+
# 2072| ValueCategory = prvalue
15738+
# 2072| getArgument(0): [VariableAccess] x
15739+
# 2072| Type = [IntType] int
15740+
# 2072| Value = [VariableAccess] 116
15741+
# 2072| ValueCategory = prvalue(load)
15742+
# 2073| getStmt(2): [ReturnStmt] return ...
1571915743
perf-regression.cpp:
1572015744
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1572115745
# 4| <params>:

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,5 +2065,11 @@ int virtual_delete()
20652065
delete d;
20662066
}
20672067

2068+
void test_constant_folding_use(int);
2069+
2070+
void test_constant_folding() {
2071+
const int x = 116;
2072+
test_constant_folding_use(x);
2073+
}
20682074

20692075
// semmle-extractor-options: -std=c++17 --clang

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9796,6 +9796,18 @@
97969796
| ir.cpp:2065:12:2065:12 | Address | &:r2065_2 |
97979797
| ir.cpp:2065:12:2065:12 | Arg(0) | 0:r2065_3 |
97989798
| ir.cpp:2065:12:2065:12 | Load | m2064_15 |
9799+
| ir.cpp:2070:6:2070:26 | ChiPartial | partial:m2070_3 |
9800+
| ir.cpp:2070:6:2070:26 | ChiTotal | total:m2070_2 |
9801+
| ir.cpp:2070:6:2070:26 | SideEffect | ~m2072_6 |
9802+
| ir.cpp:2071:13:2071:13 | Address | &:r2071_1 |
9803+
| ir.cpp:2071:16:2071:19 | StoreValue | r2071_2 |
9804+
| ir.cpp:2072:3:2072:27 | CallTarget | func:r2072_1 |
9805+
| ir.cpp:2072:3:2072:27 | ChiPartial | partial:m2072_5 |
9806+
| ir.cpp:2072:3:2072:27 | ChiTotal | total:m2070_4 |
9807+
| ir.cpp:2072:3:2072:27 | SideEffect | ~m2070_4 |
9808+
| ir.cpp:2072:29:2072:29 | Address | &:r2072_2 |
9809+
| ir.cpp:2072:29:2072:29 | Arg(0) | 0:r2072_3 |
9810+
| ir.cpp:2072:29:2072:29 | Load | ~m2070_4 |
97999811
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
98009812
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
98019813
| 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
@@ -11303,6 +11303,24 @@ ir.cpp:
1130311303
# 2056| v2056_6(void) = AliasedUse : ~m?
1130411304
# 2056| v2056_7(void) = ExitFunction :
1130511305

11306+
# 2070| void test_constant_folding()
11307+
# 2070| Block 0
11308+
# 2070| v2070_1(void) = EnterFunction :
11309+
# 2070| mu2070_2(unknown) = AliasedDefinition :
11310+
# 2070| mu2070_3(unknown) = InitializeNonLocal :
11311+
# 2071| r2071_1(glval<int>) = VariableAddress[x] :
11312+
# 2071| r2071_2(int) = Constant[116] :
11313+
# 2071| mu2071_3(int) = Store[x] : &:r2071_1, r2071_2
11314+
# 2072| r2072_1(glval<unknown>) = FunctionAddress[test_constant_folding_use] :
11315+
# 2072| r2072_2(glval<int>) = Constant[116] :
11316+
# 2072| r2072_3(int) = Load[?] : &:r2072_2, ~m?
11317+
# 2072| v2072_4(void) = Call[test_constant_folding_use] : func:r2072_1, 0:r2072_3
11318+
# 2072| mu2072_5(unknown) = ^CallSideEffect : ~m?
11319+
# 2073| v2073_1(void) = NoOp :
11320+
# 2070| v2070_4(void) = ReturnVoid :
11321+
# 2070| v2070_5(void) = AliasedUse : ~m?
11322+
# 2070| v2070_6(void) = ExitFunction :
11323+
1130611324
perf-regression.cpp:
1130711325
# 6| void Big::Big()
1130811326
# 6| Block 0

0 commit comments

Comments
 (0)