Skip to content

Commit fbb0ffc

Browse files
committed
C++: Add testcase with invalid IR from vacuous destructor call.
1 parent 4bb725c commit fbb0ffc

10 files changed

+582
-0
lines changed

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

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17160,6 +17160,167 @@ ir.cpp:
1716017160
# 2190| getExpr(): [ConstructorCall] call to ClassWithDestructor
1716117161
# 2190| Type = [VoidType] void
1716217162
# 2190| ValueCategory = prvalue
17163+
# 2194| [FunctionTemplateInstantiation,TopLevelFunction] ClassWithDestructor& vacuous_destructor_call::get<ClassWithDestructor>(ClassWithDestructor&)
17164+
# 2194| <params>:
17165+
# 2194| getParameter(0): [Parameter] t
17166+
# 2194| Type = [LValueReferenceType] ClassWithDestructor &
17167+
# 2194| getEntryPoint(): [BlockStmt] { ... }
17168+
# 2194| getStmt(0): [ReturnStmt] return ...
17169+
# 2194| getExpr(): [VariableAccess] t
17170+
# 2194| Type = [LValueReferenceType] ClassWithDestructor &
17171+
# 2194| ValueCategory = prvalue(load)
17172+
# 2194| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
17173+
# 2194| Type = [LValueReferenceType] ClassWithDestructor &
17174+
# 2194| ValueCategory = prvalue
17175+
# 2194| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
17176+
# 2194| Type = [Class] ClassWithDestructor
17177+
# 2194| ValueCategory = lvalue
17178+
# 2194| [TemplateFunction,TopLevelFunction] T& vacuous_destructor_call::get<T>(T&)
17179+
# 2194| <params>:
17180+
# 2194| getParameter(0): [Parameter] t
17181+
# 2194| Type = [LValueReferenceType] T &
17182+
# 2194| getEntryPoint(): [BlockStmt] { ... }
17183+
# 2194| getStmt(0): [ReturnStmt] return ...
17184+
# 2194| getExpr(): [VariableAccess] t
17185+
# 2194| Type = [LValueReferenceType] T &
17186+
# 2194| ValueCategory = prvalue(load)
17187+
# 2194| getExpr().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
17188+
# 2194| Type = [TemplateParameter] T
17189+
# 2194| ValueCategory = lvalue
17190+
# 2194| [FunctionTemplateInstantiation,TopLevelFunction] int& vacuous_destructor_call::get<int>(int&)
17191+
# 2194| <params>:
17192+
# 2194| getParameter(0): [Parameter] t
17193+
# 2194| Type = [LValueReferenceType] int &
17194+
# 2194| getEntryPoint(): [BlockStmt] { ... }
17195+
# 2194| getStmt(0): [ReturnStmt] return ...
17196+
# 2194| getExpr(): [VariableAccess] t
17197+
# 2194| Type = [LValueReferenceType] int &
17198+
# 2194| ValueCategory = prvalue(load)
17199+
# 2194| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
17200+
# 2194| Type = [LValueReferenceType] int &
17201+
# 2194| ValueCategory = prvalue
17202+
# 2194| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
17203+
# 2194| Type = [IntType] int
17204+
# 2194| ValueCategory = lvalue
17205+
# 2197| [FunctionTemplateInstantiation,TopLevelFunction] void vacuous_destructor_call::call_destructor<ClassWithDestructor>(ClassWithDestructor&)
17206+
# 2197| <params>:
17207+
# 2197| getParameter(0): [Parameter] t
17208+
# 2197| Type = [LValueReferenceType] ClassWithDestructor &
17209+
# 2197| getEntryPoint(): [BlockStmt] { ... }
17210+
# 2198| getStmt(0): [ExprStmt] ExprStmt
17211+
# 2198| getExpr(): [DestructorCall] call to ~ClassWithDestructor
17212+
# 2198| Type = [VoidType] void
17213+
# 2198| ValueCategory = prvalue
17214+
# 2198| getQualifier(): [FunctionCall] call to get
17215+
# 2198| Type = [LValueReferenceType] ClassWithDestructor &
17216+
# 2198| ValueCategory = prvalue
17217+
# 2198| getArgument(0): [VariableAccess] t
17218+
# 2198| Type = [LValueReferenceType] ClassWithDestructor &
17219+
# 2198| ValueCategory = prvalue(load)
17220+
# 2198| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
17221+
# 2198| Type = [LValueReferenceType] ClassWithDestructor &
17222+
# 2198| ValueCategory = prvalue
17223+
# 2198| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
17224+
# 2198| Type = [Class] ClassWithDestructor
17225+
# 2198| ValueCategory = lvalue
17226+
# 2198| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
17227+
# 2198| Type = [Class] ClassWithDestructor
17228+
# 2198| ValueCategory = lvalue
17229+
# 2199| getStmt(1): [ReturnStmt] return ...
17230+
# 2197| [TemplateFunction,TopLevelFunction] void vacuous_destructor_call::call_destructor<T>(T&)
17231+
# 2197| <params>:
17232+
# 2197| getParameter(0): [Parameter] t
17233+
# 2197| Type = [LValueReferenceType] T &
17234+
# 2197| getEntryPoint(): [BlockStmt] { ... }
17235+
# 2198| getStmt(0): [ExprStmt] ExprStmt
17236+
# 2198| getExpr(): [ExprCall] call to expression
17237+
# 2198| Type = [UnknownType] unknown
17238+
# 2198| ValueCategory = prvalue
17239+
# 2198| getExpr(): [Literal] Unknown literal
17240+
# 2198| Type = [UnknownType] unknown
17241+
# 2198| ValueCategory = prvalue
17242+
# 2198| getChild(-1): [ExprCall] call to expression
17243+
# 2198| Type = [UnknownType] unknown
17244+
# 2198| ValueCategory = prvalue
17245+
# 2198| getExpr(): [Literal] Unknown literal
17246+
# 2198| Type = [UnknownType] unknown
17247+
# 2198| ValueCategory = prvalue
17248+
# 2198| getArgument(0): [VariableAccess] t
17249+
# 2198| Type = [LValueReferenceType] T &
17250+
# 2198| ValueCategory = prvalue(load)
17251+
# 2198| getArgument(0).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
17252+
# 2198| Type = [TemplateParameter] T
17253+
# 2198| ValueCategory = lvalue
17254+
# 2199| getStmt(1): [ReturnStmt] return ...
17255+
# 2197| [FunctionTemplateInstantiation,TopLevelFunction] void vacuous_destructor_call::call_destructor<int>(int&)
17256+
# 2197| <params>:
17257+
# 2197| getParameter(0): [Parameter] t
17258+
# 2197| Type = [LValueReferenceType] int &
17259+
# 2197| getEntryPoint(): [BlockStmt] { ... }
17260+
# 2198| getStmt(0): [ExprStmt] ExprStmt
17261+
# 2198| getExpr(): [VacuousDestructorCall] (vacuous destructor call)
17262+
# 2198| Type = [VoidType] void
17263+
# 2198| ValueCategory = prvalue
17264+
# 2198| getChild(0): [FunctionCall] call to get
17265+
# 2198| Type = [LValueReferenceType] int &
17266+
# 2198| ValueCategory = prvalue
17267+
# 2198| getArgument(0): [VariableAccess] t
17268+
# 2198| Type = [LValueReferenceType] int &
17269+
# 2198| ValueCategory = prvalue(load)
17270+
# 2198| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
17271+
# 2198| Type = [LValueReferenceType] int &
17272+
# 2198| ValueCategory = prvalue
17273+
# 2198| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
17274+
# 2198| Type = [IntType] int
17275+
# 2198| ValueCategory = lvalue
17276+
# 2198| getChild(0).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
17277+
# 2198| Type = [IntType] int
17278+
# 2198| ValueCategory = lvalue
17279+
# 2199| getStmt(1): [ReturnStmt] return ...
17280+
# 2201| [TopLevelFunction] void vacuous_destructor_call::non_vacuous_destructor_call()
17281+
# 2201| <params>:
17282+
# 2201| getEntryPoint(): [BlockStmt] { ... }
17283+
# 2202| getStmt(0): [DeclStmt] declaration
17284+
# 2202| getDeclarationEntry(0): [VariableDeclarationEntry] definition of c
17285+
# 2202| Type = [Class] ClassWithDestructor
17286+
# 2202| getVariable().getInitializer(): [Initializer] initializer for c
17287+
# 2202| getExpr(): [ConstructorCall] call to ClassWithDestructor
17288+
# 2202| Type = [VoidType] void
17289+
# 2202| ValueCategory = prvalue
17290+
# 2203| getStmt(1): [ExprStmt] ExprStmt
17291+
# 2203| getExpr(): [FunctionCall] call to call_destructor
17292+
# 2203| Type = [VoidType] void
17293+
# 2203| ValueCategory = prvalue
17294+
# 2203| getArgument(0): [VariableAccess] c
17295+
# 2203| Type = [Class] ClassWithDestructor
17296+
# 2203| ValueCategory = lvalue
17297+
# 2203| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
17298+
# 2203| Type = [LValueReferenceType] ClassWithDestructor &
17299+
# 2203| ValueCategory = prvalue
17300+
# 2204| getStmt(2): [ReturnStmt] return ...
17301+
# 2204| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
17302+
# 2204| Type = [VoidType] void
17303+
# 2204| ValueCategory = prvalue
17304+
# 2204| getQualifier(): [VariableAccess] c
17305+
# 2204| Type = [Class] ClassWithDestructor
17306+
# 2204| ValueCategory = lvalue
17307+
# 2206| [TopLevelFunction] void vacuous_destructor_call::vacuous_destructor_call()
17308+
# 2206| <params>:
17309+
# 2206| getEntryPoint(): [BlockStmt] { ... }
17310+
# 2207| getStmt(0): [DeclStmt] declaration
17311+
# 2207| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
17312+
# 2207| Type = [IntType] int
17313+
# 2208| getStmt(1): [ExprStmt] ExprStmt
17314+
# 2208| getExpr(): [FunctionCall] call to call_destructor
17315+
# 2208| Type = [VoidType] void
17316+
# 2208| ValueCategory = prvalue
17317+
# 2208| getArgument(0): [VariableAccess] i
17318+
# 2208| Type = [IntType] int
17319+
# 2208| ValueCategory = lvalue
17320+
# 2208| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
17321+
# 2208| Type = [LValueReferenceType] int &
17322+
# 2208| ValueCategory = prvalue
17323+
# 2209| getStmt(2): [ReturnStmt] return ...
1716317324
perf-regression.cpp:
1716417325
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1716517326
# 4| <params>:

0 commit comments

Comments
 (0)