Index: llvm/include/llvm/Demangle/MicrosoftDemangle.h =================================================================== --- llvm/include/llvm/Demangle/MicrosoftDemangle.h +++ llvm/include/llvm/Demangle/MicrosoftDemangle.h @@ -158,6 +158,7 @@ QualifiedNameNode *QN); SymbolNode *demangleDeclarator(StringView &MangledName); SymbolNode *demangleMD5Name(StringView &MangledName); + SymbolNode *demangleTypeinfoName(StringView &MangledName); VariableSymbolNode *demangleVariableEncoding(StringView &MangledName, StorageClass SC); Index: llvm/lib/Demangle/MicrosoftDemangle.cpp =================================================================== --- llvm/lib/Demangle/MicrosoftDemangle.cpp +++ llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -783,8 +783,26 @@ 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); Index: llvm/test/Demangle/invalid-manglings.test =================================================================== --- llvm/test/Demangle/invalid-manglings.test +++ llvm/test/Demangle/invalid-manglings.test @@ -374,3 +374,8 @@ ; CHECK-EMPTY: ; CHECK-NEXT: ??_P ; CHECK-NEXT: error: Invalid mangled name + +.?AUBase@@@8 +; CHECK-EMPTY: +; CHECK-NEXT: .?AUBase@@@8 +; CHECK-NEXT: error: Invalid mangled name Index: llvm/test/Demangle/ms-operators.test =================================================================== --- llvm/test/Demangle/ms-operators.test +++ llvm/test/Demangle/ms-operators.test @@ -209,6 +209,9 @@ ??_R0?AUBase@@@8 ; CHECK: struct Base `RTTI Type Descriptor' +.?AUBase@@ +; CHECK: struct Base `RTTI Type Descriptor Name' + ??_R1A@?0A@EA@Base@@8 ; CHECK: Base::`RTTI Base Class Descriptor at (0, -1, 0, 64)'