llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Reid Kleckner (rnk)

<details>
<summary>Changes</summary>

This behavior is true for all attributes, but this behavior can be surprising 
for attributes which have function-wide effects, such as `optnone` and 
`target`. Most other function attributes affect the prototype or semantics, but 
do not affect code generation in the function body. I believe it is worth 
calling this out in the documentation of these function-wide attributes. There 
may be more, these were the two that came to mind.

---
Full diff: https://github.com/llvm/llvm-project/pull/82815.diff


1 Files Affected:

- (modified) clang/include/clang/Basic/AttrDocs.td (+9) 


``````````diff
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b96fbddd51154c..3c58256c77201f 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2486,6 +2486,9 @@ Example "subtarget features" from the x86 backend 
include: "mmx", "sse", "sse4.2
 "avx", "xop" and largely correspond to the machine specific options handled by
 the front end.
 
+Note that this attribute does not apply transitively to nested functions such
+as blocks or C++ lambdas.
+
 Additionally, this attribute supports function multiversioning for ELF based
 x86/x86-64 targets, which can be used to create multiple implementations of the
 same function that will be resolved at runtime based on the priority of their
@@ -3714,6 +3717,12 @@ for that function.
 
 This attribute is incompatible with the ``always_inline`` and ``minsize``
 attributes.
+
+Note that this attribute does not apply recursively to nested functions such as
+lambdas or blocks when using declaration-specific attribute syntaxes such as 
double
+square brackets (``[[]]``) or ``__attribute__``. The ``#pragma`` syntax can be
+used to apply the attribute to all functions, including nested functions, in a
+range of source code.
   }];
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/82815
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to