[clang] a5d4ba7 - [clang][doc] Document and prefer __asm as mangled name attribute (#167226)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 10 06:44:46 PST 2025
Author: Raul Tambre
Date: 2025-11-10T16:44:43+02:00
New Revision: a5d4ba7be4399c8b4aca9e841ca1d145c7fb57f3
URL: https://github.com/llvm/llvm-project/commit/a5d4ba7be4399c8b4aca9e841ca1d145c7fb57f3
DIFF: https://github.com/llvm/llvm-project/commit/a5d4ba7be4399c8b4aca9e841ca1d145c7fb57f3.diff
LOG: [clang][doc] Document and prefer __asm as mangled name attribute (#167226)
It's supported together with the other spellings and results in the same attribute.
Document it and prefer it in the documentation as the `asm()` spelling is C++ and GNU-only.
See: https://github.com/llvm/llvm-project/pull/167221#issuecomment-3508464545
Added:
Modified:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 1013bfc575747..da608370645ac 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1069,7 +1069,7 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
}
def AsmLabel : InheritableAttr {
- let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
+ let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm">, CustomKeyword<"__asm__">];
let Args = [
// Label specifies the mangled name for the decl.
StringArgument<"Label">, ];
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 1be9a96aa44de..f1dbd8af6093a 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4295,17 +4295,17 @@ used by other languages. (This prefix is also added to the standard Itanium
C++ ABI prefix on "mangled" symbol names, so that e.g. on such targets the true
symbol name for a C++ variable declared as ``int cppvar;`` would be
``__Z6cppvar``; note the two underscores.) This prefix is *not* added to the
-symbol names specified by the ``asm`` attribute; programmers wishing to match a
-C symbol name must compensate for this.
+symbol names specified by the ``__asm`` attribute; programmers wishing to match
+a C symbol name must compensate for this.
For example, consider the following C code:
.. code-block:: c
- int var1 asm("altvar") = 1; // "altvar" in symbol table.
+ int var1 __asm("altvar") = 1; // "altvar" in symbol table.
int var2 = 1; // "_var2" in symbol table.
- void func1(void) asm("altfunc");
+ void func1(void) __asm("altfunc");
void func1(void) {} // "altfunc" in symbol table.
void func2(void) {} // "_func2" in symbol table.
More information about the cfe-commits
mailing list