https://github.com/tambry created 
https://github.com/llvm/llvm-project/pull/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

>From f32e61865569cd1e3cab5c4b81b092b89c4a38a5 Mon Sep 17 00:00:00 2001
From: Raul Tambre <[email protected]>
Date: Sun, 9 Nov 2025 17:40:51 +0200
Subject: [PATCH] [clang][doc] Document and prefer __asm as mangled name
 attribute

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.
---
 clang/include/clang/Basic/Attr.td     | 2 +-
 clang/include/clang/Basic/AttrDocs.td | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

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.
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to