diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-05-27 23:10:42 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-05-27 23:10:42 +0000 |
commit | 82dc06c340f248e5e5530f607fead15ccfcfde43 (patch) | |
tree | 11b63be6d0d268bd24a7832b95ea511c6f363579 /llvm/lib/Demangle | |
parent | 23343c5d90bb6a047506a9977a36d225a934d023 (diff) | |
download | bcm5719-llvm-82dc06c340f248e5e5530f607fead15ccfcfde43.tar.gz bcm5719-llvm-82dc06c340f248e5e5530f607fead15ccfcfde43.zip |
llvm-undname: Extract demangleMD5Name() method; no behavior change
llvm-svn: 361783
Diffstat (limited to 'llvm/lib/Demangle')
-rw-r--r-- | llvm/lib/Demangle/MicrosoftDemangle.cpp | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index c1e6e14fd49..912ca64d76d 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -745,38 +745,42 @@ SymbolNode *Demangler::demangleDeclarator(StringView &MangledName) { 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??@...@??@...@8 + // instead of_CT??@...@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??@...@??@...@8 - // instead of_CT??@...@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('?')) { |