Author: Reid Kleckner
Date: 2024-05-03T13:50:27-07:00
New Revision: 4e6d30e2c17fa2be3bc5106c2541fddb62b2d4ee

URL: 
https://github.com/llvm/llvm-project/commit/4e6d30e2c17fa2be3bc5106c2541fddb62b2d4ee
DIFF: 
https://github.com/llvm/llvm-project/commit/4e6d30e2c17fa2be3bc5106c2541fddb62b2d4ee.diff

LOG: [clang] Note that optnone and target attributes do not apply to nested 
functions (#82815)

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.

Added: 
    

Modified: 
    clang/include/clang/Basic/AttrDocs.td

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a0bbe5861c5722..f8253143b596c0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2527,6 +2527,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
@@ -3782,6 +3785,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.
   }];
 }
 


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

Reply via email to