-
Notifications
You must be signed in to change notification settings - Fork 15k
[Clang] Clarify the [[trivial_abi]]
documentation.
#143243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Corentin Jabot (cor3ntin) ChangesFixes #36667 Full diff: https://github.com/llvm/llvm-project/pull/143243.diff 1 Files Affected:
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 40b9f8142bb69..19d5a76246bf0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -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 a 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 pointer to themselves.
Attribute ``trivial_abi`` has no effect in the following cases:
|
``__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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like...
When used as a function argument, this attribute instructs the compiler it may omit the call to the copy constructor. Thus, side effects of the copy constructor are potentially not executed. For example, objects that contain pointers to themselves or sub-objects that would be updated during a copy should not be marked as trivial.
I'm not THRILLED with my last sentence, so feel free to come up with somethign better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
executed -> invoked?
1b8013a
to
002d009
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/12538 Here is the relevant piece of the build log for the reference
|
Fixes #36667