C++: Add testcase with invalid IR.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-08-31 20:35:33 +01:00
parent da64ea40b9
commit b575747357
4 changed files with 60 additions and 0 deletions

View File

@@ -15716,6 +15716,30 @@ ir.cpp:
# 2065| Type = [PointerType] Derived2 *
# 2065| ValueCategory = prvalue(load)
# 2066| getStmt(6): [ReturnStmt] return ...
# 2068| [TopLevelFunction] void test_constant_folding_use(int)
# 2068| <params>:
# 2068| getParameter(0): [Parameter] (unnamed parameter 0)
# 2068| Type = [IntType] int
# 2070| [TopLevelFunction] void test_constant_folding()
# 2070| <params>:
# 2070| getEntryPoint(): [BlockStmt] { ... }
# 2071| getStmt(0): [DeclStmt] declaration
# 2071| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
# 2071| Type = [SpecifiedType] const int
# 2071| getVariable().getInitializer(): [Initializer] initializer for x
# 2071| getExpr(): [Literal] 116
# 2071| Type = [IntType] int
# 2071| Value = [Literal] 116
# 2071| ValueCategory = prvalue
# 2072| getStmt(1): [ExprStmt] ExprStmt
# 2072| getExpr(): [FunctionCall] call to test_constant_folding_use
# 2072| Type = [VoidType] void
# 2072| ValueCategory = prvalue
# 2072| getArgument(0): [VariableAccess] x
# 2072| Type = [IntType] int
# 2072| Value = [VariableAccess] 116
# 2072| ValueCategory = prvalue(load)
# 2073| getStmt(2): [ReturnStmt] return ...
perf-regression.cpp:
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
# 4| <params>:

View File

@@ -2065,5 +2065,11 @@ int virtual_delete()
delete d;
}
void test_constant_folding_use(int);
void test_constant_folding() {
const int x = 116;
test_constant_folding_use(x);
}
// semmle-extractor-options: -std=c++17 --clang

View File

@@ -9796,6 +9796,18 @@
| ir.cpp:2065:12:2065:12 | Address | &:r2065_2 |
| ir.cpp:2065:12:2065:12 | Arg(0) | 0:r2065_3 |
| ir.cpp:2065:12:2065:12 | Load | m2064_15 |
| ir.cpp:2070:6:2070:26 | ChiPartial | partial:m2070_3 |
| ir.cpp:2070:6:2070:26 | ChiTotal | total:m2070_2 |
| ir.cpp:2070:6:2070:26 | SideEffect | ~m2072_6 |
| ir.cpp:2071:13:2071:13 | Address | &:r2071_1 |
| ir.cpp:2071:16:2071:19 | StoreValue | r2071_2 |
| ir.cpp:2072:3:2072:27 | CallTarget | func:r2072_1 |
| ir.cpp:2072:3:2072:27 | ChiPartial | partial:m2072_5 |
| ir.cpp:2072:3:2072:27 | ChiTotal | total:m2070_4 |
| ir.cpp:2072:3:2072:27 | SideEffect | ~m2070_4 |
| ir.cpp:2072:29:2072:29 | Address | &:r2072_2 |
| ir.cpp:2072:29:2072:29 | Arg(0) | 0:r2072_3 |
| ir.cpp:2072:29:2072:29 | Load | ~m2070_4 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

View File

@@ -11303,6 +11303,24 @@ ir.cpp:
# 2056| v2056_6(void) = AliasedUse : ~m?
# 2056| v2056_7(void) = ExitFunction :
# 2070| void test_constant_folding()
# 2070| Block 0
# 2070| v2070_1(void) = EnterFunction :
# 2070| mu2070_2(unknown) = AliasedDefinition :
# 2070| mu2070_3(unknown) = InitializeNonLocal :
# 2071| r2071_1(glval<int>) = VariableAddress[x] :
# 2071| r2071_2(int) = Constant[116] :
# 2071| mu2071_3(int) = Store[x] : &:r2071_1, r2071_2
# 2072| r2072_1(glval<unknown>) = FunctionAddress[test_constant_folding_use] :
# 2072| r2072_2(glval<int>) = Constant[116] :
# 2072| r2072_3(int) = Load[?] : &:r2072_2, ~m?
# 2072| v2072_4(void) = Call[test_constant_folding_use] : func:r2072_1, 0:r2072_3
# 2072| mu2072_5(unknown) = ^CallSideEffect : ~m?
# 2073| v2073_1(void) = NoOp :
# 2070| v2070_4(void) = ReturnVoid :
# 2070| v2070_5(void) = AliasedUse : ~m?
# 2070| v2070_6(void) = ExitFunction :
perf-regression.cpp:
# 6| void Big::Big()
# 6| Block 0