[llvm] 44f7929 - [Demangle] Support demangling Swift calling convention in MS demangler.
Varun Gandhi via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 27 13:25:05 PST 2021
Author: Varun Gandhi
Date: 2021-01-27T13:24:54-08:00
New Revision: 44f792966e0f2935ea9e0ce96a4f35e01bfe6b61
URL: https://github.com/llvm/llvm-project/commit/44f792966e0f2935ea9e0ce96a4f35e01bfe6b61
DIFF: https://github.com/llvm/llvm-project/commit/44f792966e0f2935ea9e0ce96a4f35e01bfe6b61.diff
LOG: [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
Added:
Modified:
clang/lib/AST/MicrosoftMangle.cpp
llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
llvm/test/Demangle/ms-mangle.test
Removed:
################################################################################
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index df6c566abc7d..9eac3586c871 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2684,6 +2684,7 @@ void MicrosoftCXXNameMangler::mangleCallingConvention(CallingConv CC) {
// ::= I # __fastcall
// ::= J # __export __fastcall
// ::= Q # __vectorcall
+ // ::= S # __attribute__((__swiftcall__)) // Clang-only
// ::= w # __regcall
// The 'export' calling conventions are from a bygone era
// (*cough*Win16*cough*) when functions were declared for export with
diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
index 62e0f4765a69..bcc63b6ef5cb 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -67,6 +67,7 @@ enum class CallingConv : uint8_t {
Eabi,
Vectorcall,
Regcall,
+ Swift, // Clang-only
};
enum class ReferenceKind : uint8_t { None, LValueRef, RValueRef };
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index 16074314a84d..2596eed71e23 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -1711,6 +1711,8 @@ CallingConv Demangler::demangleCallingConvention(StringView &MangledName) {
return CallingConv::Eabi;
case 'Q':
return CallingConv::Vectorcall;
+ case 'S':
+ return CallingConv::Swift;
}
return CallingConv::None;
diff --git a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
index 8b15ffcee778..0a3ba6d69ac9 100644
--- a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
@@ -107,6 +107,9 @@ static void outputCallingConvention(OutputStream &OS, CallingConv CC) {
case CallingConv::Clrcall:
OS << "__clrcall";
break;
+ case CallingConv::Swift:
+ OS << "__attribute__((__swiftcall__)) ";
+ break;
default:
break;
}
diff --git a/llvm/test/Demangle/ms-mangle.test b/llvm/test/Demangle/ms-mangle.test
index bbac3ebb9971..c77802ca0e85 100644
--- a/llvm/test/Demangle/ms-mangle.test
+++ b/llvm/test/Demangle/ms-mangle.test
@@ -338,6 +338,9 @@
?vector_func@@YQXXZ
; CHECK: void __vectorcall vector_func(void)
+?swift_func@@YSXXZ
+; CHECK: void __attribute__((__swiftcall__)) swift_func(void)
+
??$fn_tmpl@$1?extern_c_func@@YAXXZ@@YAXXZ
; CHECK: void __cdecl fn_tmpl<&void __cdecl extern_c_func(void)>(void)
More information about the llvm-commits
mailing list