llvm.org GIT mirror llvm / f4448ba
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350656 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 8 months ago
5 changed file(s) with 38 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
244244 FuncClass demangleFunctionClass(StringView &MangledName);
245245 CallingConv demangleCallingConvention(StringView &MangledName);
246246 StorageClass demangleVariableStorageClass(StringView &MangledName);
247 void demangleThrowSpecification(StringView &MangledName);
247 bool demangleThrowSpecification(StringView &MangledName);
248248 wchar_t demangleWcharLiteral(StringView &MangledName);
249249 uint8_t demangleCharLiteral(StringView &MangledName);
250250
322322
323323 // Function parameters
324324 NodeArrayNode *Params = nullptr;
325
326 // True if the function type is noexcept
327 bool IsNoexcept = false;
325328 };
326329
327330 struct IdentifierNode : public Node {
16801680 return Ty;
16811681 }
16821682
1683 void Demangler::demangleThrowSpecification(StringView &MangledName) {
1683 bool Demangler::demangleThrowSpecification(StringView &MangledName) {
1684 if (MangledName.consumeFront("_E"))
1685 return true;
16841686 if (MangledName.consumeFront('Z'))
1685 return;
1687 return false;
16861688
16871689 Error = true;
1690 return false;
16881691 }
16891692
16901693 FunctionSignatureNode *Demangler::demangleFunctionType(StringView &MangledName,
17081711
17091712 FTy->Params = demangleFunctionParameterList(MangledName);
17101713
1711 demangleThrowSpecification(MangledName);
1714 FTy->IsNoexcept = demangleThrowSpecification(MangledName);
17121715
17131716 return FTy;
17141717 }
422422 if (Quals & Q_Unaligned)
423423 OS << " __unaligned";
424424
425 if (IsNoexcept)
426 OS << " noexcept";
427
425428 if (RefQualifier == FunctionRefQualifier::Reference)
426429 OS << " &";
427430 else if (RefQualifier == FunctionRefQualifier::RValueReference)
0 ; RUN: llvm-undname < %s | FileCheck %s
1
2 ; CHECK-NOT: Invalid mangled name
3
4 ?nochange@@YAXXZ
5 ; CHECK: void __cdecl nochange(void)
6
7 ?a@@YAXP6AHXZ@Z
8 ; CHECK: void __cdecl a(int (__cdecl *)(void))
9 ?a@@YAXP6AHX_E@Z
10 ; CHECK: void __cdecl a(int (__cdecl *)(void) noexcept)
11
12 ?b@@YAXP6AHXZ@Z
13 ; CHECK: void __cdecl b(int (__cdecl *)(void))
14
15 ?c@@YAXP6AHXZ@Z
16 ; CHECK: void __cdecl c(int (__cdecl *)(void))
17 ?c@@YAXP6AHX_E@Z
18 ; CHECK: void __cdecl c(int (__cdecl *)(void) noexcept)
19
20 ?ee@?$e@$$A6AXXZ@@EEAAXXZ
21 ; CHECK: private: virtual void __cdecl e::ee(void)
22
23 ?ee@?$e@$$A6AXX_E@@EEAAXXZ
24 ; CHECK: private: virtual void __cdecl e::ee(void)