NBB_Simple = 1 << 1, // save simple names.
};
-enum class SymbolCategory { Function, Variable };
+enum class SymbolCategory { Function, Variable, Unknown };
namespace {
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>();
}
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
--- /dev/null
+; 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