diff --git a/demumble_test.py b/demumble_test.py index 2e0097b..2a6d9ab 100755 --- a/demumble_test.py +++ b/demumble_test.py @@ -39,6 +39,7 @@ ('demumble -bx < bar', re.compile(".*unrecognized option `x' in `-bx'.*")), ('demumble < _ZZ3fooiENK3$_0clEi', 'foo(int)::$_0::operator()(int) const\n'), + ('demumble .?AVNet@@', "class Net `RTTI Type Descriptor Name'\n"), ] status = 0 diff --git a/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h b/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h index 382e794..c6f2606 100644 --- a/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h +++ b/third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h @@ -158,6 +158,7 @@ class Demangler { QualifiedNameNode *QN); SymbolNode *demangleDeclarator(StringView &MangledName); SymbolNode *demangleMD5Name(StringView &MangledName); + SymbolNode *demangleTypeinfoName(StringView &MangledName); VariableSymbolNode *demangleVariableEncoding(StringView &MangledName, StorageClass SC); diff --git a/third_party/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/third_party/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h index 3d47471..37abede 100644 --- a/third_party/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h +++ b/third_party/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h @@ -303,8 +303,6 @@ struct TypeNode : public Node { outputPost(OS, Flags); } - void outputQuals(bool SpaceBefore, bool SpaceAfter) const; - Qualifiers Quals = Q_None; }; diff --git a/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp b/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp index bf7d776..4be6e5a 100644 --- a/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -783,8 +783,26 @@ SymbolNode *Demangler::demangleMD5Name(StringView &MangledName) { return S; } +SymbolNode *Demangler::demangleTypeinfoName(StringView &MangledName) { + assert(MangledName.startsWith('.')); + MangledName.consumeFront('.'); + + TypeNode *T = demangleType(MangledName, QualifierMangleMode::Result); + if (Error || !MangledName.empty()) { + Error = true; + return nullptr; + } + return synthesizeVariable(Arena, T, "`RTTI Type Descriptor Name'"); +} + // Parser entry point. SymbolNode *Demangler::parse(StringView &MangledName) { + // Typeinfo names are strings stored in RTTI data. They're not symbol names. + // It's still useful to demangle them. They're the only demangled entity + // that doesn't start with a "?" but a ".". + if (MangledName.startsWith('.')) + return demangleTypeinfoName(MangledName); + if (MangledName.startsWith("??@")) return demangleMD5Name(MangledName); diff --git a/third_party/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp b/third_party/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp index 63ca475..10363dc 100644 --- a/third_party/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp +++ b/third_party/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp @@ -120,8 +120,6 @@ std::string Node::toString(OutputFlags Flags) const { return {OS.getBuffer()}; } -void TypeNode::outputQuals(bool SpaceBefore, bool SpaceAfter) const {} - void PrimitiveTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const { switch (PrimKind) { OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Void, "void");