]> granicus.if.org Git - clang/commit
Don't copy objects with trivial, deleted copy ctors
authorReid Kleckner <reid@kleckner.net>
Wed, 14 May 2014 16:02:09 +0000 (16:02 +0000)
committerReid Kleckner <reid@kleckner.net>
Wed, 14 May 2014 16:02:09 +0000 (16:02 +0000)
commit13ec00d6d7dbed25cfdc202ca482de2ecb41c61b
tree0a3996a3fd9ef1d617d3aa5fbb61ba4655123789
parentb51314cc3e1eb7bd67a27fb1a8410b01cf4c6895
Don't copy objects with trivial, deleted copy ctors

This affects both the Itanium and Microsoft C++ ABIs.

This is in anticipation of a change to the Itanium C++ ABI, and should
match GCC's current behavior.  The new text will likely be:

"""
Pass an object of class type by value if every copy constructor and
move constructor is deleted or trivial and at least one of them is not
deleted, and the destructor is trivial.
"""
http://sourcerytools.com/pipermail/cxx-abi-dev/2014-May/002728.html

On x86 Windows, we can mostly use the same logic, where we use inalloca
instead of passing by address.  However, on Win64, there are register
parameters, and we have to do what MSVC does.  MSVC ignores the presence
of non-trivial move constructors and only considers the presence of
non-trivial or deleted copy constructors.  If a non-trivial or deleted
copy ctor is present, it passes the argument indirectly.

This change fixes bugs and makes us more ABI compatible with both GCC
and MSVC.

Fixes PR19668.

Reviewers: rsmith

Differential Revision: http://reviews.llvm.org/D3660

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208786 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGCXXABI.cpp
lib/CodeGen/CGCXXABI.h
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/uncopyable-args.cpp [new file with mode: 0644]