Add support for attribute 'trivial_abi'.
authorAkira Hatanaka <ahatanaka@apple.com>
Mon, 5 Feb 2018 20:23:22 +0000 (20:23 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Mon, 5 Feb 2018 20:23:22 +0000 (20:23 +0000)
commit02914dc1278cf9b472e9cd4357d641b5dd3f5834
treeea2b88bc4177716dd38b8cacae2c87d7d90567ff
parent02f6845095ee1ea0e54824a650a8f4c5d0ffd156
Add support for attribute 'trivial_abi'.

The 'trivial_abi' attribute can be applied to a C++ class, struct, or
union. It makes special functions of the annotated class (the destructor
and copy/move constructors) to be trivial for the purpose of calls and,
as a result, enables the annotated class or containing classes to be
passed or returned using the C ABI for the underlying type.

When a type that is considered trivial for the purpose of calls despite
having a non-trivial destructor (which happens only when the class type
or one of its subobjects is a 'trivial_abi' class) is passed to a
function, the callee is responsible for destroying the object.

For more background, see the discussions that took place on the mailing
list:

http://lists.llvm.org/pipermail/cfe-dev/2017-November/055955.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180101/thread.html#214043

rdar://problem/35204524

Differential Revision: https://reviews.llvm.org/D41039

llvm-svn: 324269
27 files changed:
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CodeGenCXX/trivial_abi.cpp [new file with mode: 0644]
clang/test/CodeGenObjCXX/trivial_abi.mm [new file with mode: 0644]
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/SemaObjCXX/attr-trivial-abi.mm [new file with mode: 0644]