[PATCH] D67851: llvm-undname: Add support for demangling typeinfo names
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 11:21:02 PDT 2019
thakis created this revision.
thakis added a reviewer: hans.
Herald added subscribers: erik.pilkington, hiraditya.
Herald added a project: LLVM.
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.
https://reviews.llvm.org/D67851
Files:
llvm/include/llvm/Demangle/MicrosoftDemangle.h
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/test/Demangle/invalid-manglings.test
llvm/test/Demangle/ms-operators.test
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 at EA@Base@@8
; CHECK: Base::`RTTI Base Class Descriptor at (0, -1, 0, 64)'
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/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/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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67851.221076.patch
Type: text/x-patch
Size: 2542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190920/0e30cba8/attachment.bin>
More information about the llvm-commits
mailing list