From 6b02d46daeab3d3d06205f2ecf89fcd0f70a8bc8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 8 Dec 2012 08:32:28 +0000 Subject: Finish implementing 'selected constructor' rules for triviality in C++11. In the cases where we can't determine whether special members would be trivial while building the class, we eagerly declare those special members. The impact of this is bounded, since it does not trigger implicit declarations of special members in classes which merely *use* those classes. In order to determine whether we need to apply this rule, we also need to eagerly declare move operations and destructors in cases where they might be deleted. If a move operation were supposed to be deleted, it would instead be suppressed, and we could need overload resolution to determine if we fall back to a trivial copy operation. If a destructor were implicitly deleted, it would cause the move constructor of any derived classes to be suppressed. As discussed on cxx-abi-dev, C++11's selected constructor rules are also retroactively applied as a defect resolution in C++03 mode, in order to identify that class B has a non-trivial copy constructor (since it calls A's constructor template, not A's copy constructor): struct A { template A(T &); }; struct B { mutable A a; }; llvm-svn: 169673 --- clang/lib/Serialization/ASTWriter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/lib/Serialization/ASTWriter.cpp') diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index f89ae2ef128..ff98d9beb05 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4589,6 +4589,12 @@ void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Rec Record.push_back(Data.HasOnlyCMembers); Record.push_back(Data.HasInClassInitializer); Record.push_back(Data.HasUninitializedReferenceMember); + Record.push_back(Data.NeedOverloadResolutionForMoveConstructor); + Record.push_back(Data.NeedOverloadResolutionForMoveAssignment); + Record.push_back(Data.NeedOverloadResolutionForDestructor); + Record.push_back(Data.DefaultedMoveConstructorIsDeleted); + Record.push_back(Data.DefaultedMoveAssignmentIsDeleted); + Record.push_back(Data.DefaultedDestructorIsDeleted); Record.push_back(Data.HasTrivialSpecialMembers); Record.push_back(Data.HasIrrelevantDestructor); Record.push_back(Data.HasConstexprNonCopyMoveConstructor); -- cgit v1.2.3