Skip to content

Commit a5d4ba7

Browse files
authored
[clang][doc] Document and prefer __asm as mangled name attribute (llvm#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: llvm#167221 (comment)
1 parent 5b20453 commit a5d4ba7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
10691069
}
10701070

10711071
def AsmLabel : InheritableAttr {
1072-
let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
1072+
let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm">, CustomKeyword<"__asm__">];
10731073
let Args = [
10741074
// Label specifies the mangled name for the decl.
10751075
StringArgument<"Label">, ];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,17 +4295,17 @@ used by other languages. (This prefix is also added to the standard Itanium
42954295
C++ ABI prefix on "mangled" symbol names, so that e.g. on such targets the true
42964296
symbol name for a C++ variable declared as ``int cppvar;`` would be
42974297
``__Z6cppvar``; note the two underscores.) This prefix is *not* added to the
4298-
symbol names specified by the ``asm`` attribute; programmers wishing to match a
4299-
C symbol name must compensate for this.
4298+
symbol names specified by the ``__asm`` attribute; programmers wishing to match
4299+
a C symbol name must compensate for this.
43004300

43014301
For example, consider the following C code:
43024302

43034303
.. code-block:: c
43044304

4305-
int var1 asm("altvar") = 1; // "altvar" in symbol table.
4305+
int var1 __asm("altvar") = 1; // "altvar" in symbol table.
43064306
int var2 = 1; // "_var2" in symbol table.
43074307

4308-
void func1(void) asm("altfunc");
4308+
void func1(void) __asm("altfunc");
43094309
void func1(void) {} // "altfunc" in symbol table.
43104310
void func2(void) {} // "_func2" in symbol table.
43114311

0 commit comments

Comments
 (0)