[clang] [Clang] Clarify the `[[trivial_abi]]` documentation. (PR #143243)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 9 07:28:53 PDT 2025
================
@@ -4431,7 +4431,11 @@ destroy the object before returning. The lifetime of the copy of the parameter
in the caller ends without a destructor call when the call begins.
If a type is trivial for the purpose of calls, it is assumed to be trivially
-relocatable for the purpose of ``__is_trivially_relocatable``.
+relocatable for the purpose of ``__is_trivially_relocatable`` and
+``__builtin_is_cpp_trivially_relocatable``.
+The copy constructor of an object of such type might not be called
+when the object is passed to a function. Therefore, the ``trivial_abi``
+attribute should not be applied to objects that contain pointers to themselves.
----------------
erichkeane wrote:
I might suggest generalizing this more... it isn't just 'pointer to themselves', it is 'does something meaningful in the copy constructor' or the 'copy constructor has some meaningful side effects'. <dont take either fo those, neither are right, but hopefully a jumping off point).
https://github.com/llvm/llvm-project/pull/143243
More information about the cfe-commits
mailing list