Skip to content

Commit 319ff35

Browse files
authored
Merge pull request #8692 from jketema/implied-cctor-source
Revert "Revert "Merge pull request #8592 from jketema/implied-cctor-source""
2 parents a6f7bd1 + bfe9fb1 commit 319ff35

File tree

6 files changed

+655
-0
lines changed

6 files changed

+655
-0
lines changed

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

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13365,6 +13365,200 @@ ir.cpp:
1336513365
# 1717| <params>:
1336613366
# 1717| getEntryPoint(): [BlockStmt] { ... }
1336713367
# 1717| getStmt(0): [ReturnStmt] return ...
13368+
# 1721| [CopyAssignmentOperator] CopyConstructorWithImplicitArgumentClass& CopyConstructorWithImplicitArgumentClass::operator=(CopyConstructorWithImplicitArgumentClass const&)
13369+
# 1721| <params>:
13370+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13371+
#-----| Type = [LValueReferenceType] const CopyConstructorWithImplicitArgumentClass &
13372+
# 1724| [Constructor] void CopyConstructorWithImplicitArgumentClass::CopyConstructorWithImplicitArgumentClass()
13373+
# 1724| <params>:
13374+
# 1724| <initializations>:
13375+
# 1724| getEntryPoint(): [BlockStmt] { ... }
13376+
# 1724| getStmt(0): [ReturnStmt] return ...
13377+
# 1725| [CopyConstructor] void CopyConstructorWithImplicitArgumentClass::CopyConstructorWithImplicitArgumentClass(CopyConstructorWithImplicitArgumentClass const&)
13378+
# 1725| <params>:
13379+
# 1725| getParameter(0): [Parameter] c
13380+
# 1725| Type = [LValueReferenceType] const CopyConstructorWithImplicitArgumentClass &
13381+
# 1725| <initializations>:
13382+
# 1725| getEntryPoint(): [BlockStmt] { ... }
13383+
# 1726| getStmt(0): [ExprStmt] ExprStmt
13384+
# 1726| getExpr(): [AssignExpr] ... = ...
13385+
# 1726| Type = [IntType] int
13386+
# 1726| ValueCategory = lvalue
13387+
# 1726| getLValue(): [PointerFieldAccess] x
13388+
# 1726| Type = [IntType] int
13389+
# 1726| ValueCategory = lvalue
13390+
# 1726| getQualifier(): [ThisExpr] this
13391+
# 1726| Type = [PointerType] CopyConstructorWithImplicitArgumentClass *
13392+
# 1726| ValueCategory = prvalue(load)
13393+
# 1726| getRValue(): [ReferenceFieldAccess] x
13394+
# 1726| Type = [IntType] int
13395+
# 1726| ValueCategory = prvalue(load)
13396+
# 1726| getQualifier(): [VariableAccess] c
13397+
# 1726| Type = [LValueReferenceType] const CopyConstructorWithImplicitArgumentClass &
13398+
# 1726| ValueCategory = prvalue(load)
13399+
# 1726| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
13400+
# 1726| Type = [SpecifiedType] const CopyConstructorWithImplicitArgumentClass
13401+
# 1726| ValueCategory = lvalue
13402+
# 1727| getStmt(1): [ReturnStmt] return ...
13403+
# 1730| [CopyAssignmentOperator] CopyConstructorWithBitwiseCopyClass& CopyConstructorWithBitwiseCopyClass::operator=(CopyConstructorWithBitwiseCopyClass const&)
13404+
# 1730| <params>:
13405+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13406+
#-----| Type = [LValueReferenceType] const CopyConstructorWithBitwiseCopyClass &
13407+
# 1730| [MoveAssignmentOperator] CopyConstructorWithBitwiseCopyClass& CopyConstructorWithBitwiseCopyClass::operator=(CopyConstructorWithBitwiseCopyClass&&)
13408+
# 1730| <params>:
13409+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13410+
#-----| Type = [RValueReferenceType] CopyConstructorWithBitwiseCopyClass &&
13411+
# 1730| [CopyConstructor] void CopyConstructorWithBitwiseCopyClass::CopyConstructorWithBitwiseCopyClass(CopyConstructorWithBitwiseCopyClass const&)
13412+
# 1730| <params>:
13413+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13414+
#-----| Type = [LValueReferenceType] const CopyConstructorWithBitwiseCopyClass &
13415+
# 1730| [MoveConstructor] void CopyConstructorWithBitwiseCopyClass::CopyConstructorWithBitwiseCopyClass(CopyConstructorWithBitwiseCopyClass&&)
13416+
# 1730| <params>:
13417+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13418+
#-----| Type = [RValueReferenceType] CopyConstructorWithBitwiseCopyClass &&
13419+
# 1733| [Constructor] void CopyConstructorWithBitwiseCopyClass::CopyConstructorWithBitwiseCopyClass()
13420+
# 1733| <params>:
13421+
# 1733| <initializations>:
13422+
# 1733| getEntryPoint(): [BlockStmt] { ... }
13423+
# 1733| getStmt(0): [ReturnStmt] return ...
13424+
# 1736| [CopyAssignmentOperator] CopyConstructorTestNonVirtualClass& CopyConstructorTestNonVirtualClass::operator=(CopyConstructorTestNonVirtualClass const&)
13425+
# 1736| <params>:
13426+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13427+
#-----| Type = [LValueReferenceType] const CopyConstructorTestNonVirtualClass &
13428+
# 1736| [MoveAssignmentOperator] CopyConstructorTestNonVirtualClass& CopyConstructorTestNonVirtualClass::operator=(CopyConstructorTestNonVirtualClass&&)
13429+
# 1736| <params>:
13430+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13431+
#-----| Type = [RValueReferenceType] CopyConstructorTestNonVirtualClass &&
13432+
# 1736| [CopyConstructor] void CopyConstructorTestNonVirtualClass::CopyConstructorTestNonVirtualClass(CopyConstructorTestNonVirtualClass const&)
13433+
# 1736| <params>:
13434+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13435+
#-----| Type = [LValueReferenceType] const CopyConstructorTestNonVirtualClass &
13436+
# 1736| <initializations>:
13437+
# 1736| getInitializer(0): [ConstructorDirectInit] call to CopyConstructorWithImplicitArgumentClass
13438+
# 1736| Type = [VoidType] void
13439+
# 1736| ValueCategory = prvalue
13440+
# 1736| getArgument(0): [VariableAccess] (unnamed parameter 0)
13441+
# 1736| Type = [LValueReferenceType] const CopyConstructorTestNonVirtualClass &
13442+
# 1736| ValueCategory = prvalue(load)
13443+
# 1736| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
13444+
# 1736| Type = [LValueReferenceType] const CopyConstructorWithImplicitArgumentClass &
13445+
# 1736| ValueCategory = prvalue
13446+
# 1736| getExpr(): [CStyleCast] (const CopyConstructorWithImplicitArgumentClass)...
13447+
# 1736| Conversion = [BaseClassConversion] base class conversion
13448+
# 1736| Type = [SpecifiedType] const CopyConstructorWithImplicitArgumentClass
13449+
# 1736| ValueCategory = lvalue
13450+
# 1736| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
13451+
# 1736| Type = [SpecifiedType] const CopyConstructorTestNonVirtualClass
13452+
# 1736| ValueCategory = lvalue
13453+
# 1736| getInitializer(1): (no string representation)
13454+
# 1736| Type = [VirtualBaseClass] CopyConstructorWithBitwiseCopyClass
13455+
# 1736| ValueCategory = prvalue
13456+
# 1736| getEntryPoint(): [BlockStmt] { ... }
13457+
# 1736| getStmt(0): [ReturnStmt] return ...
13458+
# 1736| [MoveConstructor] void CopyConstructorTestNonVirtualClass::CopyConstructorTestNonVirtualClass(CopyConstructorTestNonVirtualClass&&)
13459+
# 1736| <params>:
13460+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13461+
#-----| Type = [RValueReferenceType] CopyConstructorTestNonVirtualClass &&
13462+
# 1740| [Constructor] void CopyConstructorTestNonVirtualClass::CopyConstructorTestNonVirtualClass()
13463+
# 1740| <params>:
13464+
# 1740| <initializations>:
13465+
# 1740| getInitializer(0): [ConstructorDirectInit] call to CopyConstructorWithImplicitArgumentClass
13466+
# 1740| Type = [VoidType] void
13467+
# 1740| ValueCategory = prvalue
13468+
# 1740| getInitializer(1): [ConstructorDirectInit] call to CopyConstructorWithBitwiseCopyClass
13469+
# 1740| Type = [VoidType] void
13470+
# 1740| ValueCategory = prvalue
13471+
# 1740| getEntryPoint(): [BlockStmt] { ... }
13472+
# 1740| getStmt(0): [ReturnStmt] return ...
13473+
# 1743| [CopyAssignmentOperator] CopyConstructorTestVirtualClass& CopyConstructorTestVirtualClass::operator=(CopyConstructorTestVirtualClass const&)
13474+
# 1743| <params>:
13475+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13476+
#-----| Type = [LValueReferenceType] const CopyConstructorTestVirtualClass &
13477+
# 1743| [MoveAssignmentOperator] CopyConstructorTestVirtualClass& CopyConstructorTestVirtualClass::operator=(CopyConstructorTestVirtualClass&&)
13478+
# 1743| <params>:
13479+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13480+
#-----| Type = [RValueReferenceType] CopyConstructorTestVirtualClass &&
13481+
# 1743| [CopyConstructor] void CopyConstructorTestVirtualClass::CopyConstructorTestVirtualClass(CopyConstructorTestVirtualClass const&)
13482+
# 1743| <params>:
13483+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13484+
#-----| Type = [LValueReferenceType] const CopyConstructorTestVirtualClass &
13485+
# 1743| <initializations>:
13486+
# 1743| getInitializer(0): [ConstructorVirtualInit] call to CopyConstructorWithImplicitArgumentClass
13487+
# 1743| Type = [VoidType] void
13488+
# 1743| ValueCategory = prvalue
13489+
# 1743| getArgument(0): [VariableAccess] (unnamed parameter 0)
13490+
# 1743| Type = [LValueReferenceType] const CopyConstructorTestVirtualClass &
13491+
# 1743| ValueCategory = prvalue(load)
13492+
# 1743| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
13493+
# 1743| Type = [LValueReferenceType] const CopyConstructorWithImplicitArgumentClass &
13494+
# 1743| ValueCategory = prvalue
13495+
# 1743| getExpr(): [CStyleCast] (const CopyConstructorWithImplicitArgumentClass)...
13496+
# 1743| Conversion = [BaseClassConversion] base class conversion
13497+
# 1743| Type = [SpecifiedType] const CopyConstructorWithImplicitArgumentClass
13498+
# 1743| ValueCategory = lvalue
13499+
# 1743| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
13500+
# 1743| Type = [SpecifiedType] const CopyConstructorTestVirtualClass
13501+
# 1743| ValueCategory = lvalue
13502+
# 1743| getInitializer(1): (no string representation)
13503+
# 1743| Type = [VirtualBaseClass] CopyConstructorWithBitwiseCopyClass
13504+
# 1743| ValueCategory = prvalue
13505+
# 1743| getEntryPoint(): [BlockStmt] { ... }
13506+
# 1743| getStmt(0): [ReturnStmt] return ...
13507+
# 1743| [MoveConstructor] void CopyConstructorTestVirtualClass::CopyConstructorTestVirtualClass(CopyConstructorTestVirtualClass&&)
13508+
# 1743| <params>:
13509+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13510+
#-----| Type = [RValueReferenceType] CopyConstructorTestVirtualClass &&
13511+
# 1747| [Constructor] void CopyConstructorTestVirtualClass::CopyConstructorTestVirtualClass()
13512+
# 1747| <params>:
13513+
# 1747| <initializations>:
13514+
# 1747| getInitializer(0): [ConstructorVirtualInit] call to CopyConstructorWithImplicitArgumentClass
13515+
# 1747| Type = [VoidType] void
13516+
# 1747| ValueCategory = prvalue
13517+
# 1747| getInitializer(1): [ConstructorVirtualInit] call to CopyConstructorWithBitwiseCopyClass
13518+
# 1747| Type = [VoidType] void
13519+
# 1747| ValueCategory = prvalue
13520+
# 1747| getEntryPoint(): [BlockStmt] { ... }
13521+
# 1747| getStmt(0): [ReturnStmt] return ...
13522+
# 1750| [TopLevelFunction] int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&)
13523+
# 1750| <params>:
13524+
# 1751| getParameter(0): [Parameter] x
13525+
# 1751| Type = [LValueReferenceType] const CopyConstructorTestNonVirtualClass &
13526+
# 1752| getParameter(1): [Parameter] y
13527+
# 1752| Type = [LValueReferenceType] const CopyConstructorTestVirtualClass &
13528+
# 1752| getEntryPoint(): [BlockStmt] { ... }
13529+
# 1753| getStmt(0): [DeclStmt] declaration
13530+
# 1753| getDeclarationEntry(0): [VariableDeclarationEntry] definition of cx
13531+
# 1753| Type = [Class] CopyConstructorTestNonVirtualClass
13532+
# 1753| getVariable().getInitializer(): [Initializer] initializer for cx
13533+
# 1753| getExpr(): [ConstructorCall] call to CopyConstructorTestNonVirtualClass
13534+
# 1753| Type = [VoidType] void
13535+
# 1753| ValueCategory = prvalue
13536+
# 1753| getArgument(0): [VariableAccess] x
13537+
# 1753| Type = [LValueReferenceType] const CopyConstructorTestNonVirtualClass &
13538+
# 1753| ValueCategory = prvalue(load)
13539+
# 1753| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
13540+
# 1753| Type = [LValueReferenceType] const CopyConstructorTestNonVirtualClass &
13541+
# 1753| ValueCategory = prvalue
13542+
# 1753| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
13543+
# 1753| Type = [SpecifiedType] const CopyConstructorTestNonVirtualClass
13544+
# 1753| ValueCategory = lvalue
13545+
# 1754| getStmt(1): [DeclStmt] declaration
13546+
# 1754| getDeclarationEntry(0): [VariableDeclarationEntry] definition of cy
13547+
# 1754| Type = [Class] CopyConstructorTestVirtualClass
13548+
# 1754| getVariable().getInitializer(): [Initializer] initializer for cy
13549+
# 1754| getExpr(): [ConstructorCall] call to CopyConstructorTestVirtualClass
13550+
# 1754| Type = [VoidType] void
13551+
# 1754| ValueCategory = prvalue
13552+
# 1754| getArgument(0): [VariableAccess] y
13553+
# 1754| Type = [LValueReferenceType] const CopyConstructorTestVirtualClass &
13554+
# 1754| ValueCategory = prvalue(load)
13555+
# 1754| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
13556+
# 1754| Type = [LValueReferenceType] const CopyConstructorTestVirtualClass &
13557+
# 1754| ValueCategory = prvalue
13558+
# 1754| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
13559+
# 1754| Type = [SpecifiedType] const CopyConstructorTestVirtualClass
13560+
# 1754| ValueCategory = lvalue
13561+
# 1755| getStmt(2): [ReturnStmt] return ...
1336813562
perf-regression.cpp:
1336913563
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1337013564
# 4| <params>:

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,4 +1718,40 @@ void captured_lambda2(TrivialLambdaClass p1, TrivialLambdaClass &p2, TrivialLamb
17181718
};
17191719
}
17201720

1721+
class CopyConstructorWithImplicitArgumentClass {
1722+
int x;
1723+
public:
1724+
CopyConstructorWithImplicitArgumentClass() {}
1725+
CopyConstructorWithImplicitArgumentClass(const CopyConstructorWithImplicitArgumentClass &c) {
1726+
x = c.x;
1727+
}
1728+
};
1729+
1730+
class CopyConstructorWithBitwiseCopyClass {
1731+
int y;
1732+
public:
1733+
CopyConstructorWithBitwiseCopyClass() {}
1734+
};
1735+
1736+
class CopyConstructorTestNonVirtualClass :
1737+
public CopyConstructorWithImplicitArgumentClass,
1738+
public CopyConstructorWithBitwiseCopyClass {
1739+
public:
1740+
CopyConstructorTestNonVirtualClass() {}
1741+
};
1742+
1743+
class CopyConstructorTestVirtualClass :
1744+
public virtual CopyConstructorWithImplicitArgumentClass,
1745+
public virtual CopyConstructorWithBitwiseCopyClass {
1746+
public:
1747+
CopyConstructorTestVirtualClass() {}
1748+
};
1749+
1750+
int implicit_copy_constructor_test(
1751+
const CopyConstructorTestNonVirtualClass &x,
1752+
const CopyConstructorTestVirtualClass &y) {
1753+
CopyConstructorTestNonVirtualClass cx = x;
1754+
CopyConstructorTestVirtualClass cy = y;
1755+
}
1756+
17211757
// semmle-extractor-options: -std=c++17 --clang

0 commit comments

Comments
 (0)