<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Would it be better if we disallowed trivial_abi if the class’ copy and move destructors were all deleted (and revert r350920)? I think that would make it easier to reason about when you are allowed to use trivial_abi and what effect the attribute has (which is to override the trivialness for the purpose of calls).<div class=""><div><br class=""></div><div>Sorry for my late reply. It took a while to understand that the patch I committed might not be the right way to fix the problem.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none; float: none; display: inline !important;" class="">On 16 Jan 2019, at 20:03, Richard Smith wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class="">On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">On 16 Jan 2019, at 18:32, Richard Smith wrote:<br class=""><br class=""><blockquote type="cite" class="">On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">On 16 Jan 2019, at 9:13, Aaron Ballman wrote:<br class=""><br class=""><blockquote type="cite" class="">On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka <<a href="mailto:ahatanaka@apple.com" class="">ahatanaka@apple.com</a>><br class="">wrote:<br class=""><blockquote type="cite" class=""><br class="">Yes, the behavior of the compiler doesn’t match what’s explained<br class="">in the documentation anymore.<br class=""><br class="">Please take a look at the attached patch, which updates the<br class="">documentation.<br class=""></blockquote><br class="">Patch mostly LGTM, but I did have one wording suggestion.<br class=""><br class=""><blockquote type="cite" class="">diff --git a/include/clang/Basic/AttrDocs.td<br class="">b/include/clang/Basic/AttrDocs.td<br class="">index 5773a92c9c..ca3cfcf9b2 100644<br class="">--- a/include/clang/Basic/AttrDocs.td<br class="">+++ b/include/clang/Basic/AttrDocs.td<br class="">@@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {<br class="">  let Category = DocCatVariable;<br class="">  let Content = [{<br class="">The ``trivial_abi`` attribute can be applied to a C++ class, struct,<br class="">or union.<br class="">-It instructs the compiler to pass and return the type using the C<br class="">ABI for the<br class="">+``trivial_abi`` has the following effects:<br class="">+<br class="">+- It instructs the compiler to pass and return the type using the C<br class="">ABI for the<br class="">underlying type when the type would otherwise be considered<br class="">non-trivial for the<br class="">purpose of calls.<br class="">-A class annotated with `trivial_abi` can have non-trivial<br class="">destructors or copy/move constructors without automatically becoming<br class="">non-trivial for the purposes of calls. For example:<br class="">+- It makes the destructor and copy and move constructors of the<br class="">class trivial<br class="">+that would otherwise be considered non-trivial under the C++ ABI<br class="">rules.<br class=""></blockquote><br class="">How about: It makes the destructor, copy constructors, and move<br class="">constructors of the class trivial even if they would otherwise be<br class="">non-trivial under the C++ ABI rules.<br class=""></blockquote><br class="">Let's not say that it makes them trivial, because it doesn't.  It causes<br class="">their immediate non-triviality to be ignored for the purposes of<br class="">deciding<br class="">whether the type can be passed in registers.<br class=""><br class=""></blockquote><br class="">Given the attribute now forces the type to be passed in registers, I<br class=""></blockquote>think<br class=""><blockquote type="cite" class="">it'd be more to the point to say that it makes the triviality of those<br class="">special members be ignored when deciding whether to pass a type with a<br class="">subobject of this type in registers.<br class=""></blockquote><br class="">Wait, it forces it to be passed in registers?  I thought the design<br class="">was that it didn't override the non-trivial-abi-ness of subobjects;<br class="">see all the discussion of trivially_relocatable.<br class=""><br class=""></blockquote><br class="">The attribute is ill-formed if applied to a class that has a subobject that<br class="">can't be passed in registers (or that has a vptr). And then as a weird<br class="">special case we don't instantiate the attribute when instantiating a class<br class="">if it would be ill-formed (well, we instantiate it and then remove it<br class="">again, but the effect is the same).<br class=""><br class="">The commit at the start of this email chain switches us from the "just<br class="">override the trivialness for the purposes of the ABI" model to /also/<br class="">forcing the type to be passed in registers (the type would otherwise not be<br class="">passed in registers in some corner cases, such as if all its copy/move<br class="">special members are deleted).<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none; float: none; display: inline !important;" class="">I see.  Alright, I accept your wording, then.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none; float: none; display: inline !important;" class="">John.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none; float: none; display: inline !important;" class="">cfe-commits mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><a href="mailto:cfe-commits@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">cfe-commits@lists.llvm.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;" class=""></div></blockquote></div><br class=""></div></body></html>