summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-02-05 20:23:22 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-02-05 20:23:22 +0000
commit9018322d0ffb51099c9a6ca7827bf14a2d2805d1 (patch)
treec174bc7470cdba186de0ea1048a003388788c648 /lib/Sema/SemaTemplateInstantiate.cpp
parent9658e036b90bc92b86c96a213d89fe87475701db (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index a48e2466a8..313d99cf45 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2108,6 +2108,10 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
}
}
+ // See if trivial_abi has to be dropped.
+ if (Instantiation && Instantiation->hasAttr<TrivialABIAttr>())
+ checkIllFormedTrivialABIStruct(*Instantiation);
+
// Finish checking fields.
ActOnFields(nullptr, Instantiation->getLocation(), Instantiation, Fields,
SourceLocation(), SourceLocation(), nullptr);