llvm-undname: Add support for demangling typeinfo names

typeinfo names aren't symbols but string constant contents
stored in compiler-generated typeinfo objects, but llvm-cxxfilt
can demangle these for Itanium names.

In the MSVC ABI, these are just a '.' followed by a mangled
type -- this means they don't start with '?' like all MS-mangled
symbols do.

Differential Revision: https://reviews.llvm.org/D67851

llvm-svn: 372602
This commit is contained in:
Nico Weber 2019-09-23 13:13:37 +00:00
parent ddc9a06e95
commit da298aa913
4 changed files with 27 additions and 0 deletions

View File

@ -158,6 +158,7 @@ private:
QualifiedNameNode *QN);
SymbolNode *demangleDeclarator(StringView &MangledName);
SymbolNode *demangleMD5Name(StringView &MangledName);
SymbolNode *demangleTypeinfoName(StringView &MangledName);
VariableSymbolNode *demangleVariableEncoding(StringView &MangledName,
StorageClass SC);

View File

@ -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);

View File

@ -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

View File

@ -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)'