From 9f3329b9c93516919634a0b2fb7f7d9a5839b9d2 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 19 Sep 2019 23:23:27 -0400 Subject: [PATCH] demo hack for #9 --- demumble.cc | 7 ++++--- .../llvm/include/llvm/Demangle/MicrosoftDemangle.h | 2 +- third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp | 10 +++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/demumble.cc b/demumble.cc index 835dbbe..f91f523 100644 --- a/demumble.cc +++ b/demumble.cc @@ -101,7 +101,7 @@ int main(int argc, char* argv[]) { char* end = cur + strlen(cur); while (cur != end) { - size_t special = strcspn(cur, "_?"); + size_t special = strcspn(cur, "_?."); if (print_mode == kPrintAll) printf("%.*s", static_cast(special), cur); else if (need_separator) @@ -112,9 +112,10 @@ int main(int argc, char* argv[]) { break; size_t n_sym = 0; - if (*cur == '?') - while (cur + n_sym != end && is_mangle_char_win(cur[n_sym])) + if (*cur == '?' || *cur == '.') + do ++n_sym; + while (cur + n_sym != end && is_mangle_char_win(cur[n_sym])); else if (is_plausible_itanium_prefix(cur)) while (cur + n_sym != end && is_mangle_char_itanium(cur[n_sym])) ++n_sym; diff --git a/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h b/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h index 382e794..45db2d5 100644 --- a/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h +++ b/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h @@ -153,7 +153,7 @@ class Demangler { void dumpBackReferences(); -private: +//private: SymbolNode *demangleEncodedSymbol(StringView &MangledName, QualifiedNameNode *QN); SymbolNode *demangleDeclarator(StringView &MangledName); diff --git a/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp b/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp index bf7d776..8e523fb 100644 --- a/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -2323,7 +2323,13 @@ char *llvm::microsoftDemangle(const char *MangledName, char *Buf, size_t *N, OutputStream S; StringView Name{MangledName}; - SymbolNode *AST = D.parse(Name); + Node *AST = nullptr; + bool wasTypeinfoName = false; + if (Name.consumeFront('.')) { + wasTypeinfoName = true; + AST = D.demangleType(Name, QualifierMangleMode::Result); + } else + AST = D.parse(Name); if (Flags & MSDF_DumpBackrefs) D.dumpBackReferences(); @@ -2333,6 +2339,8 @@ char *llvm::microsoftDemangle(const char *MangledName, char *Buf, size_t *N, else if (!initializeOutputStream(Buf, N, S, 1024)) InternalStatus = demangle_memory_alloc_failure; else { + if (wasTypeinfoName) + S << "typeinfo name for "; AST->output(S, OF_Default); S += '\0'; if (N != nullptr)