PR19668, PR23034: Fix handling of move constructors and deleted copy
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Aug 2017 19:12:28 +0000 (19:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Aug 2017 19:12:28 +0000 (19:12 +0000)
commitf1a425edb7d742a2ad697fa5dea7bc1dbfa9e533
treea5d16a8b3d8a3ffc18ec2a2e4552836fab40b5a5
parentf5266f03a86b8be756cb2bc263d80b88dd3dff85
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

 * Previously, Clang ignored the move constructor when making this
   determination. It now takes the move constructor into account, per
   https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
   seem recent, but the ABI change was agreed on the Itanium C++ ABI
   list a long time ago).

 * Previously, Clang's behavior when the copy constructor was deleted
   was unstable -- depending on whether the lazy declaration of the
   copy constructor had been triggered, you might get different behavior.
   We now eagerly declare the copy constructor whenever its deletedness
   is unclear, and ignore deleted copy/move constructors when looking for
   a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

 * If the copy constructor would be implicitly deleted (but has not been
   lazily declared yet), for instance because the class has an rvalue
   reference member, we would pass it directly. We now pass such a class
   indirectly, matching MSVC.

llvm-svn: 310401
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGCXXABI.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CodeGenCXX/uncopyable-args.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp