<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=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 16, 2019, at 4:20 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=""><div class=""><br class=""><br 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 think<br 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=""></div></div></blockquote><div><br class=""></div><div>As stated in the documentation, trivial_abi on a class has no effect when one of its subobject is non-trivial for the purpose of calls. In the following example, clang (Sema::checkIllFormedTrivialABIStruct) issues a warning and drops the attribute on D since B is non-trivial:</div><div><br class=""></div><div>struct B {</div><div>  B(const B &);</div><div>};</div><div><br class=""></div><div>struct __attribute__((trivial_abi)) D {  // <span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(219, 39, 218);" class=""><b class="">warning: </b></span><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">'trivial_abi' cannot be applied to ‘D' [-Wignored-attributes]</span></font></b></span></div><div>  B b;</div><div>};</div><div><br class=""></div><div>If the attribute on the class survives the check by Sema::checkIllFormedTrivialABIStruct, the class is treated as being trivial for the purposes of calls.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class="">John.<br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits<br class=""></div></div></blockquote></div><br class=""></body></html>