diff options
author | Zachary Turner <zturner@google.com> | 2018-08-16 16:17:17 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-08-16 16:17:17 +0000 |
commit | 83313f8f54b4a0da8fda13bc6e90043b8137bf7f (patch) | |
tree | 13efc74675391fbe4d465b6549c70d1d6529adf3 | |
parent | 0e1813390520a06820070188829c46ce9c7dbd28 (diff) | |
download | bcm5719-llvm-83313f8f54b4a0da8fda13bc6e90043b8137bf7f.tar.gz bcm5719-llvm-83313f8f54b4a0da8fda13bc6e90043b8137bf7f.zip |
[MS Demangler] Don't fail on MD5-mangled names.
When we have an MD5 mangled name, we shouldn't choke and say
that it's an invalid name. Even though it's impossible to demangle,
we should just output the original name.
llvm-svn: 339891
-rw-r--r-- | llvm/lib/Demangle/MicrosoftDemangle.cpp | 15 | ||||
-rw-r--r-- | llvm/test/Demangle/ms-md5.test | 11 |
2 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 0af93e1519b..99a1f23503a 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -213,7 +213,7 @@ enum NameBackrefBehavior : uint8_t { NBB_Simple = 1 << 1, // save simple names. }; -enum class SymbolCategory { Function, Variable }; +enum class SymbolCategory { Function, Variable, Unknown }; namespace { @@ -1051,6 +1051,15 @@ StringView Demangler::copyString(StringView Borrowed) { Symbol *Demangler::parse(StringView &MangledName) { Symbol *S = Arena.alloc<Symbol>(); + // We can't demangle MD5 names, just output them as-is. + if (MangledName.startsWith("??@")) { + S->Category = SymbolCategory::Unknown; + S->SymbolName = Arena.alloc<Name>(); + S->SymbolName->Str = MangledName; + MangledName = StringView(); + return S; + } + // MSVC-style mangled symbols must start with '?'. if (!MangledName.consumeFront("?")) { S->SymbolName = Arena.alloc<Name>(); @@ -2180,6 +2189,10 @@ StringView Demangler::resolve(StringView N) { } void Demangler::output(const Symbol *S, OutputStream &OS) { + if (S->Category == SymbolCategory::Unknown) { + outputName(OS, S->SymbolName, S->SymbolType, *this); + return; + } // Converts an AST to a string. // // Converting an AST representing a C++ type to a string is tricky due diff --git a/llvm/test/Demangle/ms-md5.test b/llvm/test/Demangle/ms-md5.test new file mode 100644 index 00000000000..1fe2ecbcb68 --- /dev/null +++ b/llvm/test/Demangle/ms-md5.test @@ -0,0 +1,11 @@ +; These tests are based on clang/test/CodeGenCXX/mangle-ms-cxx11.cpp + +; RUN: llvm-undname < %s | FileCheck %s + +; CHECK-NOT: Invalid mangled name + +; MD5-mangled names start with ??@ and we should output them as is. We have +; two check lines here since the tool echos the input. +??@a6a285da2eea70dba6b578022be61d81@ +; CHECK: ??@a6a285da2eea70dba6b578022be61d81@ +; CHECK-NEXT: ??@a6a285da2eea70dba6b578022be61d81@
\ No newline at end of file |