Finish implementing 'selected constructor' rules for triviality in C++11. In
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 8 Dec 2012 08:32:28 +0000 (08:32 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 8 Dec 2012 08:32:28 +0000 (08:32 +0000)
commit6b02d46daeab3d3d06205f2ecf89fcd0f70a8bc8
treefea2d0fe42a02fff7e6f1a6e1b93684b9f4ad4f0
parent6ebca4be3300d3a9e45054b342ad4f8c58be3015
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<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/special/class.copy/p12-0x.cpp
clang/test/CXX/special/class.copy/p25-0x.cpp
clang/test/PCH/cxx0x-default-delete.cpp
clang/test/SemaCXX/type-traits.cpp