Skip to content

Commit 9c52b3c

Browse files
authored
[Clang] Clarify the [[trivial_abi]] documentation. (#143243)
Fixes #36667
1 parent 637df70 commit 9c52b3c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4433,7 +4433,14 @@ destroy the object before returning. The lifetime of the copy of the parameter
44334433
in the caller ends without a destructor call when the call begins.
44344434

44354435
If a type is trivial for the purpose of calls, it is assumed to be trivially
4436-
relocatable for the purpose of ``__is_trivially_relocatable``.
4436+
relocatable for the purpose of ``__is_trivially_relocatable`` and
4437+
``__builtin_is_cpp_trivially_relocatable``.
4438+
When a type marked with ``[[trivial_abi]]`` is used as a function argument,
4439+
the compiler may omit the call to the copy constructor.
4440+
Thus, side effects of the copy constructor are potentially not performed.
4441+
For example, objects that contain pointers to themselves or otherwise depend
4442+
on their address (or the address or their subobjects) should not be declared
4443+
``[[trivial_abi]]``.
44374444

44384445
Attribute ``trivial_abi`` has no effect in the following cases:
44394446

0 commit comments

Comments
 (0)