[llvm] r361783 - llvm-undname: Extract demangleMD5Name() method; no behavior change
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon May 27 16:10:43 PDT 2019
Author: nico
Date: Mon May 27 16:10:42 2019
New Revision: 361783
URL: http://llvm.org/viewvc/llvm-project?rev=361783&view=rev
Log:
llvm-undname: Extract demangleMD5Name() method; no behavior change
Modified:
llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
Modified: llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h?rev=361783&r1=361782&r2=361783&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h (original)
+++ llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h Mon May 27 16:10:42 2019
@@ -157,6 +157,7 @@ private:
SymbolNode *demangleEncodedSymbol(StringView &MangledName,
QualifiedNameNode *QN);
SymbolNode *demangleDeclarator(StringView &MangledName);
+ SymbolNode *demangleMD5Name(StringView &MangledName);
VariableSymbolNode *demangleVariableEncoding(StringView &MangledName,
StorageClass SC);
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=361783&r1=361782&r2=361783&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Mon May 27 16:10:42 2019
@@ -745,38 +745,42 @@ SymbolNode *Demangler::demangleDeclarato
return Symbol;
}
+SymbolNode *Demangler::demangleMD5Name(StringView &MangledName) {
+ assert(MangledName.startsWith("??@"));
+ // This is an MD5 mangled name. We can't demangle it, just return the
+ // mangled name.
+ // An MD5 mangled name is ??@ followed by 32 characters and a terminating @.
+ size_t MD5Last = MangledName.find('@', strlen("??@"));
+ if (MD5Last == StringView::npos) {
+ Error = true;
+ return nullptr;
+ }
+ const char *Start = MangledName.begin();
+ MangledName = MangledName.dropFront(MD5Last + 1);
+
+ // There are two additional special cases for MD5 names:
+ // 1. For complete object locators where the object name is long enough
+ // for the object to have an MD5 name, the complete object locator is
+ // called ??@...@??_R4@ (with a trailing "??_R4@" instead of the usual
+ // leading "??_R4". This is handled here.
+ // 2. For catchable types, in versions of MSVC before 2015 (<1900) or after
+ // 2017.2 (>= 1914), the catchable type mangling is _CT??@...@??@... at 8
+ // instead of_CT??@... at 8 with just one MD5 name. Since we don't yet
+ // demangle catchable types anywhere, this isn't handled for MD5 names
+ // either.
+ MangledName.consumeFront("??_R4@");
+
+ StringView MD5(Start, MangledName.begin());
+ SymbolNode *S = Arena.alloc<SymbolNode>(NodeKind::Md5Symbol);
+ S->Name = synthesizeQualifiedName(Arena, MD5);
+
+ return S;
+}
+
// Parser entry point.
SymbolNode *Demangler::parse(StringView &MangledName) {
- if (MangledName.startsWith("??@")) {
- // This is an MD5 mangled name. We can't demangle it, just return the
- // mangled name.
- // An MD5 mangled name is ??@ followed by 32 characters and a terminating @.
- size_t MD5Last = MangledName.find('@', strlen("??@"));
- if (MD5Last == StringView::npos) {
- Error = true;
- return nullptr;
- }
- const char* Start = MangledName.begin();
- MangledName = MangledName.dropFront(MD5Last + 1);
-
- // There are two additional special cases for MD5 names:
- // 1. For complete object locators where the object name is long enough
- // for the object to have an MD5 name, the complete object locator is
- // called ??@...@??_R4@ (with a trailing "??_R4@" instead of the usual
- // leading "??_R4". This is handled here.
- // 2. For catchable types, in versions of MSVC before 2015 (<1900) or after
- // 2017.2 (>= 1914), the catchable type mangling is _CT??@...@??@... at 8
- // instead of_CT??@... at 8 with just one MD5 name. Since we don't yet
- // demangle catchable types anywhere, this isn't handled for MD5 names
- // either.
- MangledName.consumeFront("??_R4@");
-
- StringView MD5(Start, MangledName.begin());
- SymbolNode *S = Arena.alloc<SymbolNode>(NodeKind::Md5Symbol);
- S->Name = synthesizeQualifiedName(Arena, MD5);
-
- return S;
- }
+ if (MangledName.startsWith("??@"))
+ return demangleMD5Name(MangledName);
// MSVC-style mangled symbols must start with '?'.
if (!MangledName.startsWith('?')) {
More information about the llvm-commits
mailing list