gulfem added inline comments.

================
Comment at: clang/include/clang/Basic/AttrDocs.td:3910
+in library functions. Functions marked with the ``leaf`` attribute are not 
allowed
+to jump back into the caller's translation unit, whether through invoking a
+callback function, a direct external function call, use of ``longjmp``, or 
other means.
----------------
I think this property is transitive. 
If a leaf function somehow enters into caller's translation unit (either via 
direct call or a via its call chain), it will violate the rule that says "Calls 
to external functions with this attribute must return to the current 
compilation unit only by return or by exception handling". 
Entering via its call chain is not a return or an exception handling.
Do you agree with that?


================
Comment at: clang/include/clang/Basic/AttrDocs.td:3910
+Functions marked as ``leaf`` attribute are not allowed to enter their caller's 
translation unit.
+Therefore, they cannot use or modify any data that does not escape the current 
compilation unit.
+
----------------
aaron.ballman wrote:
> What sort of diagnostic checking should the user expect? e.g., can the user 
> expect Clang to diagnose obviously incorrect code like:
> ```
> [[gnu::leaf]] void func(void (*fp)(void)) {
>   fp(); // This seems like a bad thing
> }
> ```
This is a compiler hint provided by the user, and if the user misuses that 
attribute, it might result in undefined behavior.
I think it might be difficult to fully verify that leaf function does not enter 
into caller's translation unit.
For this simple case you provided, it might be easy to add such a check.
However, it might be difficult to add such checks for complicated cases.
Therefore, we were not planning to add such kind of diagnostic checking.
What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90275/new/

https://reviews.llvm.org/D90275

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to