Skip to content

Commit 44f7929

Browse files
[Demangle] Support demangling Swift calling convention in MS demangler.
Previously, Clang was able to mangle the Swift calling convention but 'MicrosoftDemangle.cpp' was not able to demangle it. Reviewed By: compnerd, rnk Differential Revision: https://reviews.llvm.org/D95053
1 parent f799371 commit 44f7929

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,6 +2684,7 @@ void MicrosoftCXXNameMangler::mangleCallingConvention(CallingConv CC) {
26842684
// ::= I # __fastcall
26852685
// ::= J # __export __fastcall
26862686
// ::= Q # __vectorcall
2687+
// ::= S # __attribute__((__swiftcall__)) // Clang-only
26872688
// ::= w # __regcall
26882689
// The 'export' calling conventions are from a bygone era
26892690
// (*cough*Win16*cough*) when functions were declared for export with

llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum class CallingConv : uint8_t {
6767
Eabi,
6868
Vectorcall,
6969
Regcall,
70+
Swift, // Clang-only
7071
};
7172

7273
enum class ReferenceKind : uint8_t { None, LValueRef, RValueRef };

llvm/lib/Demangle/MicrosoftDemangle.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,8 @@ CallingConv Demangler::demangleCallingConvention(StringView &MangledName) {
17111711
return CallingConv::Eabi;
17121712
case 'Q':
17131713
return CallingConv::Vectorcall;
1714+
case 'S':
1715+
return CallingConv::Swift;
17141716
}
17151717

17161718
return CallingConv::None;

llvm/lib/Demangle/MicrosoftDemangleNodes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ static void outputCallingConvention(OutputStream &OS, CallingConv CC) {
107107
case CallingConv::Clrcall:
108108
OS << "__clrcall";
109109
break;
110+
case CallingConv::Swift:
111+
OS << "__attribute__((__swiftcall__)) ";
112+
break;
110113
default:
111114
break;
112115
}

llvm/test/Demangle/ms-mangle.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@
338338
?vector_func@@YQXXZ
339339
; CHECK: void __vectorcall vector_func(void)
340340

341+
?swift_func@@YSXXZ
342+
; CHECK: void __attribute__((__swiftcall__)) swift_func(void)
343+
341344
??$fn_tmpl@$1?extern_c_func@@YAXXZ@@YAXXZ
342345
; CHECK: void __cdecl fn_tmpl<&void __cdecl extern_c_func(void)>(void)
343346

0 commit comments

Comments
 (0)