1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[llvm-undname] Add support for demangling msvc's noexcept types.

Starting in C++17, MSVC introduced a new mangling for function
parameters that are themselves noexcept functions.  This patch
makes llvm-undname properly demangle them.

Patch by Zachary Henkel
Differential Revision: https://reviews.llvm.org/D55769

llvm-svn: 350656
This commit is contained in:
Zachary Turner 2019-01-08 21:05:51 +00:00
parent 6b32fb155c
commit 3475d3dfe8
5 changed files with 38 additions and 4 deletions

View File

@ -245,7 +245,7 @@ private:
FuncClass demangleFunctionClass(StringView &MangledName);
CallingConv demangleCallingConvention(StringView &MangledName);
StorageClass demangleVariableStorageClass(StringView &MangledName);
void demangleThrowSpecification(StringView &MangledName);
bool demangleThrowSpecification(StringView &MangledName);
wchar_t demangleWcharLiteral(StringView &MangledName);
uint8_t demangleCharLiteral(StringView &MangledName);

View File

@ -323,6 +323,9 @@ struct FunctionSignatureNode : public TypeNode {
// Function parameters
NodeArrayNode *Params = nullptr;
// True if the function type is noexcept
bool IsNoexcept = false;
};
struct IdentifierNode : public Node {

View File

@ -1681,11 +1681,14 @@ TypeNode *Demangler::demangleType(StringView &MangledName,
return Ty;
}
void Demangler::demangleThrowSpecification(StringView &MangledName) {
bool Demangler::demangleThrowSpecification(StringView &MangledName) {
if (MangledName.consumeFront("_E"))
return true;
if (MangledName.consumeFront('Z'))
return;
return false;
Error = true;
return false;
}
FunctionSignatureNode *Demangler::demangleFunctionType(StringView &MangledName,
@ -1709,7 +1712,7 @@ FunctionSignatureNode *Demangler::demangleFunctionType(StringView &MangledName,
FTy->Params = demangleFunctionParameterList(MangledName);
demangleThrowSpecification(MangledName);
FTy->IsNoexcept = demangleThrowSpecification(MangledName);
return FTy;
}

View File

@ -423,6 +423,9 @@ void FunctionSignatureNode::outputPost(OutputStream &OS,
if (Quals & Q_Unaligned)
OS << " __unaligned";
if (IsNoexcept)
OS << " noexcept";
if (RefQualifier == FunctionRefQualifier::Reference)
OS << " &";
else if (RefQualifier == FunctionRefQualifier::RValueReference)

View File

@ -0,0 +1,25 @@
; RUN: llvm-undname < %s | FileCheck %s
; CHECK-NOT: Invalid mangled name
?nochange@@YAXXZ
; CHECK: void __cdecl nochange(void)
?a@@YAXP6AHXZ@Z
; CHECK: void __cdecl a(int (__cdecl *)(void))
?a@@YAXP6AHX_E@Z
; CHECK: void __cdecl a(int (__cdecl *)(void) noexcept)
?b@@YAXP6AHXZ@Z
; CHECK: void __cdecl b(int (__cdecl *)(void))
?c@@YAXP6AHXZ@Z
; CHECK: void __cdecl c(int (__cdecl *)(void))
?c@@YAXP6AHX_E@Z
; CHECK: void __cdecl c(int (__cdecl *)(void) noexcept)
?ee@?$e@$$A6AXXZ@@EEAAXXZ
; CHECK: private: virtual void __cdecl e<void __cdecl(void)>::ee(void)
?ee@?$e@$$A6AXX_E@@EEAAXXZ
; CHECK: private: virtual void __cdecl e<void __cdecl(void) noexcept>::ee(void)