Skip to content

Commit b042366

Browse files
committed
C++: Add a failing testcase.
1 parent bb2c690 commit b042366

10 files changed

+402
-0
lines changed

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20275,6 +20275,54 @@ ir.cpp:
2027520275
# 2437| getQualifier(): [VariableAccess] c
2027620276
# 2437| Type = [Class] ClassWithDestructor
2027720277
# 2437| ValueCategory = lvalue
20278+
# 2439| [CopyAssignmentOperator] ByValueConstructor& ByValueConstructor::operator=(ByValueConstructor const&)
20279+
# 2439| <params>:
20280+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
20281+
#-----| Type = [LValueReferenceType] const ByValueConstructor &
20282+
# 2439| [MoveAssignmentOperator] ByValueConstructor& ByValueConstructor::operator=(ByValueConstructor&&)
20283+
# 2439| <params>:
20284+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
20285+
#-----| Type = [RValueReferenceType] ByValueConstructor &&
20286+
# 2439| [CopyConstructor] void ByValueConstructor::ByValueConstructor(ByValueConstructor const&)
20287+
# 2439| <params>:
20288+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
20289+
#-----| Type = [LValueReferenceType] const ByValueConstructor &
20290+
# 2439| [MoveConstructor] void ByValueConstructor::ByValueConstructor(ByValueConstructor&&)
20291+
# 2439| <params>:
20292+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
20293+
#-----| Type = [RValueReferenceType] ByValueConstructor &&
20294+
# 2440| [Constructor] void ByValueConstructor::ByValueConstructor(ClassWithDestructor)
20295+
# 2440| <params>:
20296+
# 2440| getParameter(0): [Parameter] (unnamed parameter 0)
20297+
# 2440| Type = [Class] ClassWithDestructor
20298+
# 2443| [TopLevelFunction] void new_with_destructor(ClassWithDestructor)
20299+
# 2443| <params>:
20300+
# 2443| getParameter(0): [Parameter] a
20301+
# 2443| Type = [Class] ClassWithDestructor
20302+
# 2444| getEntryPoint(): [BlockStmt] { ... }
20303+
# 2445| getStmt(0): [DeclStmt] declaration
20304+
# 2445| getDeclarationEntry(0): [VariableDeclarationEntry] definition of b
20305+
# 2445| Type = [PointerType] ByValueConstructor *
20306+
# 2445| getVariable().getInitializer(): [Initializer] initializer for b
20307+
# 2445| getExpr(): [NewExpr] new
20308+
# 2445| Type = [PointerType] ByValueConstructor *
20309+
# 2445| ValueCategory = prvalue
20310+
# 2445| getInitializer(): [ConstructorCall] call to ByValueConstructor
20311+
# 2445| Type = [VoidType] void
20312+
# 2445| ValueCategory = prvalue
20313+
# 2445| getArgument(0): [VariableAccess] a
20314+
# 2445| Type = [Class] ClassWithDestructor
20315+
# 2445| ValueCategory = prvalue(load)
20316+
# 2445| getArgument(0).getFullyConverted(): [TemporaryObjectExpr] temporary object
20317+
# 2445| Type = [Class] ClassWithDestructor
20318+
# 2445| ValueCategory = lvalue
20319+
# 2445| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
20320+
# 2445| Type = [VoidType] void
20321+
# 2445| ValueCategory = prvalue
20322+
# 2445| getQualifier(): [ReuseExpr] reuse of temporary object
20323+
# 2445| Type = [Class] ClassWithDestructor
20324+
# 2445| ValueCategory = xvalue
20325+
# 2446| getStmt(1): [ReturnStmt] return ...
2027820326
perf-regression.cpp:
2027920327
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
2028020328
# 4| <params>:

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16026,6 +16026,72 @@ ir.cpp:
1602616026
# 2434| v2434_8(void) = AliasedUse : ~m2437_5
1602716027
# 2434| v2434_9(void) = ExitFunction :
1602816028

16029+
# 2443| void new_with_destructor(ClassWithDestructor)
16030+
# 2443| Block 0
16031+
# 2443| v2443_1(void) = EnterFunction :
16032+
# 2443| m2443_2(unknown) = AliasedDefinition :
16033+
# 2443| m2443_3(unknown) = InitializeNonLocal :
16034+
# 2443| m2443_4(unknown) = Chi : total:m2443_2, partial:m2443_3
16035+
# 2443| r2443_5(glval<ClassWithDestructor>) = VariableAddress[a] :
16036+
# 2443| m2443_6(ClassWithDestructor) = InitializeParameter[a] : &:r2443_5
16037+
# 2445| r2445_1(glval<ByValueConstructor *>) = VariableAddress[b] :
16038+
# 2445| r2445_2(glval<unknown>) = FunctionAddress[operator new] :
16039+
# 2445| r2445_3(unsigned long) = Constant[1] :
16040+
#-----| Goto -> Block 4
16041+
#-----| Goto -> Block 4
16042+
16043+
# 2445| Block 1
16044+
# 2445| m2445_4(ByValueConstructor *) = Store[b] : &:r2445_1, r2445_5
16045+
# 2446| v2446_1(void) = NoOp :
16046+
# 2443| v2443_7(void) = ReturnVoid :
16047+
# 2443| v2443_8(void) = AliasedUse : ~m2445_31, ~m2445_45
16048+
# 2443| v2443_9(void) = ExitFunction :
16049+
16050+
# 2445| Block 2
16051+
# 2445| r2445_5(ByValueConstructor *) = Convert : r2445_17
16052+
# 2445| r2445_6(glval<unknown>) = FunctionAddress[ByValueConstructor] :
16053+
# 2445| r2445_7(glval<ClassWithDestructor>) = VariableAddress[#temp2445:52] :
16054+
# 2445| r2445_8(glval<ClassWithDestructor>) = VariableAddress[a] :
16055+
# 2445| r2445_9(ClassWithDestructor) = Load[a] : &:r2445_8, m2443_6
16056+
# 2445| m2445_10(ClassWithDestructor) = Store[#temp2445:52] : &:r2445_7, r2445_9
16057+
# 2445| r2445_11(ClassWithDestructor) = Load[#temp2445:52] : &:r2445_7, m2445_10
16058+
# 2445| v2445_12(void) = Call[ByValueConstructor] : func:r2445_6, this:r2445_5, 0:r2445_11
16059+
# 2445| m2445_13(unknown) = ^CallSideEffect : ~m2445_31, ~m2445_45
16060+
# 2445| m2445_14(unknown) = Chi : total:m2445_31, total:m2445_45, partial:m2445_13
16061+
# 2445| m2445_15(ByValueConstructor) = ^IndirectMayWriteSideEffect[-1] : &:r2445_5
16062+
# 2445| m2445_16(unknown) = Chi : total:m2445_22, total:m2445_25, total:m2445_36, total:m2445_39, partial:m2445_15
16063+
#-----| Goto (back edge) -> Block 4
16064+
#-----| Goto (back edge) -> Block 4
16065+
16066+
# 2445| Block 3
16067+
# 2445| r2445_17(void *) = Call[operator new] : func:r2445_2, 0:r2445_3
16068+
# 2445| m2445_18(unknown) = ^CallSideEffect : ~m2445_31, ~m2445_45
16069+
# 2445| m2445_19(unknown) = Chi : total:m2445_31, total:m2445_45, partial:m2445_18
16070+
# 2445| m2445_20(unknown) = ^InitializeDynamicAllocation : &:r2445_17
16071+
#-----| Goto (back edge) -> Block 4
16072+
#-----| Goto (back edge) -> Block 4
16073+
16074+
# 2445| Block 4
16075+
# 2445| m2445_39(unknown) = Phi : from 2:m2445_16, from 3:m2445_20
16076+
# 2445| m2445_40(unknown) = Phi : from 0:~m2443_4, from 2:~m2445_14, from 3:~m2445_19
16077+
# 2445| m2445_38(ClassWithDestructor) = Phi : from 2:m2445_10, from 3:m2445_34, from 3:m2445_48
16078+
# 2445| r2445_41(glval<ClassWithDestructor>) = CopyValue : r2445_7
16079+
# 2445| r2445_42(glval<unknown>) = FunctionAddress[~ClassWithDestructor] :
16080+
# 2445| v2445_43(void) = Call[~ClassWithDestructor] : func:r2445_28, func:r2445_42, this:r2445_27, this:r2445_41
16081+
# 2445| m2445_44(unknown) = ^CallSideEffect : ~m2445_23, ~m2445_26, ~m2445_37, ~m2445_40
16082+
# 2445| m2445_45(unknown) = Chi : total:m2445_23, total:m2445_26, total:m2445_37, total:m2445_40, partial:m2445_30, partial:m2445_44
16083+
# 2445| v2445_46(void) = ^IndirectReadSideEffect[-1] : &:r2445_27, &:r2445_41, m2445_21, m2445_24, m2445_35, m2445_38
16084+
# 2445| m2445_47(ClassWithDestructor) = ^IndirectMayWriteSideEffect[-1] : &:r2445_27, &:r2445_41
16085+
# 2445| m2445_48(ClassWithDestructor) = Chi : total:m2445_21, total:m2445_24, total:m2445_35, total:m2445_38, partial:m2445_33, partial:m2445_47
16086+
#-----| Goto (back edge) -> Block 2
16087+
#-----| Goto (back edge) -> Block 3
16088+
#-----| Goto (back edge) -> Block 1
16089+
16090+
# 2445| Block 4
16091+
#-----| Goto (back edge) -> Block 2
16092+
#-----| Goto (back edge) -> Block 3
16093+
#-----| Goto (back edge) -> Block 1
16094+
1602916095
perf-regression.cpp:
1603016096
# 6| void Big::Big()
1603116097
# 6| Block 0

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,41 @@ missingOperand
22
unexpectedOperand
33
duplicateOperand
44
missingPhiOperand
5+
| ir.cpp:2445:52:2445:52 | Phi: reuse of temporary object | Instruction 'Phi: reuse of temporary object' is missing an operand for predecessor block 'EnterFunction: new_with_destructor' in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
56
missingOperandType
67
duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
910
ambiguousSuccessors
11+
| ir.cpp:2445:52:2445:52 | Chi: reuse of temporary object | Instruction 'Chi: reuse of temporary object' has 3 successors of kind 'Goto' in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
1012
unexplainedLoop
13+
| ir.cpp:2445:29:2445:53 | Call: call to ByValueConstructor | Instruction 'Call: call to ByValueConstructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
14+
| ir.cpp:2445:29:2445:53 | Call: new | Instruction 'Call: new' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
15+
| ir.cpp:2445:29:2445:53 | CallSideEffect: call to ByValueConstructor | Instruction 'CallSideEffect: call to ByValueConstructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
16+
| ir.cpp:2445:29:2445:53 | CallSideEffect: new | Instruction 'CallSideEffect: new' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
17+
| ir.cpp:2445:29:2445:53 | Chi: call to ByValueConstructor | Instruction 'Chi: call to ByValueConstructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
18+
| ir.cpp:2445:29:2445:53 | Chi: call to ByValueConstructor | Instruction 'Chi: call to ByValueConstructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
19+
| ir.cpp:2445:29:2445:53 | Chi: new | Instruction 'Chi: new' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
20+
| ir.cpp:2445:29:2445:53 | Chi: new | Instruction 'Chi: new' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
21+
| ir.cpp:2445:29:2445:53 | Convert: new | Instruction 'Convert: new' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
22+
| ir.cpp:2445:29:2445:53 | FunctionAddress: call to ByValueConstructor | Instruction 'FunctionAddress: call to ByValueConstructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
23+
| ir.cpp:2445:29:2445:53 | IndirectMayWriteSideEffect: call to ByValueConstructor | Instruction 'IndirectMayWriteSideEffect: call to ByValueConstructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
24+
| ir.cpp:2445:29:2445:53 | InitializeDynamicAllocation: new | Instruction 'InitializeDynamicAllocation: new' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
25+
| ir.cpp:2445:52:2445:52 | Call: call to ~ClassWithDestructor | Instruction 'Call: call to ~ClassWithDestructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
26+
| ir.cpp:2445:52:2445:52 | CallSideEffect: call to ~ClassWithDestructor | Instruction 'CallSideEffect: call to ~ClassWithDestructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
27+
| ir.cpp:2445:52:2445:52 | Chi: call to ~ClassWithDestructor | Instruction 'Chi: call to ~ClassWithDestructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
28+
| ir.cpp:2445:52:2445:52 | Chi: reuse of temporary object | Instruction 'Chi: reuse of temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
29+
| ir.cpp:2445:52:2445:52 | CopyValue: reuse of temporary object | Instruction 'CopyValue: reuse of temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
30+
| ir.cpp:2445:52:2445:52 | FunctionAddress: call to ~ClassWithDestructor | Instruction 'FunctionAddress: call to ~ClassWithDestructor' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
31+
| ir.cpp:2445:52:2445:52 | IndirectMayWriteSideEffect: reuse of temporary object | Instruction 'IndirectMayWriteSideEffect: reuse of temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
32+
| ir.cpp:2445:52:2445:52 | IndirectReadSideEffect: reuse of temporary object | Instruction 'IndirectReadSideEffect: reuse of temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
33+
| ir.cpp:2445:52:2445:52 | Load: a | Instruction 'Load: a' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
34+
| ir.cpp:2445:52:2445:52 | Load: temporary object | Instruction 'Load: temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
35+
| ir.cpp:2445:52:2445:52 | Phi: reuse of temporary object | Instruction 'Phi: reuse of temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
36+
| ir.cpp:2445:52:2445:52 | Phi: reuse of temporary object | Instruction 'Phi: reuse of temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
37+
| ir.cpp:2445:52:2445:52 | Store: a | Instruction 'Store: a' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
38+
| ir.cpp:2445:52:2445:52 | VariableAddress: a | Instruction 'VariableAddress: a' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
39+
| ir.cpp:2445:52:2445:52 | VariableAddress: temporary object | Instruction 'VariableAddress: temporary object' is part of an unexplained loop in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
1140
unnecessaryPhiInstruction
1241
memoryOperandDefinitionIsUnmodeled
1342
operandAcrossFunctions
@@ -18,8 +47,14 @@ containsLoopOfForwardEdges
1847
missingIRType
1948
multipleIRTypes
2049
lostReachability
50+
| ir.cpp:2445:29:2445:53 | Call: new | Block 'Call: new' is not reachable by traversing only forward edges in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
51+
| ir.cpp:2445:29:2445:53 | Convert: new | Block 'Convert: new' is not reachable by traversing only forward edges in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
52+
| ir.cpp:2445:29:2445:53 | Store: new | Block 'Store: new' is not reachable by traversing only forward edges in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
2153
backEdgeCountMismatch
2254
useNotDominatedByDefinition
55+
| ir.cpp:2445:29:2445:53 | StoreValue | Operand 'StoreValue' is not dominated by its definition in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
56+
| ir.cpp:2445:29:2445:53 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
57+
| ir.cpp:2445:52:2445:52 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:2443:6:2443:24 | void new_with_destructor(ClassWithDestructor) | void new_with_destructor(ClassWithDestructor) |
2358
switchInstructionWithoutDefaultEdge
2459
notMarkedAsConflated
2560
wronglyMarkedAsConflated

0 commit comments

Comments
 (0)