[PATCH] D114308: [Demangle] Add support for D special identifiers
Luís Ferreira via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 19:16:27 PST 2021
ljmf00 created this revision.
ljmf00 added a project: LLVM.
Herald added a subscriber: hiraditya.
ljmf00 requested review of this revision.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114308
Files:
llvm/lib/Demangle/DLangDemangle.cpp
llvm/unittests/Demangle/DLangDemangleTest.cpp
Index: llvm/unittests/Demangle/DLangDemangleTest.cpp
===================================================================
--- llvm/unittests/Demangle/DLangDemangleTest.cpp
+++ llvm/unittests/Demangle/DLangDemangleTest.cpp
@@ -36,5 +36,13 @@
std::make_pair("_D8demangle4testZ", "demangle.test"),
std::make_pair("_D8demangle4test5test2Z", "demangle.test.test2"),
std::make_pair("_D8demangle9anonymous0Z", "demangle.anonymous"),
- std::make_pair("_D8demangle9anonymous03fooZ",
- "demangle.anonymous.foo")));
+ std::make_pair("_D8demangle9anonymous03fooZ", "demangle.anonymous.foo"),
+ std::make_pair("_D8demangle4test6__initZ",
+ "initializer for demangle.test"),
+ std::make_pair("_D8demangle4test6__vtblZ", "vtable for demangle.test"),
+ std::make_pair("_D8demangle4test7__ClassZ",
+ "ClassInfo for demangle.test"),
+ std::make_pair("_D8demangle4test11__InterfaceZ",
+ "Interface for demangle.test"),
+ std::make_pair("_D8demangle4test12__ModuleInfoZ",
+ "ModuleInfo for demangle.test")));
Index: llvm/lib/Demangle/DLangDemangle.cpp
===================================================================
--- llvm/lib/Demangle/DLangDemangle.cpp
+++ llvm/lib/Demangle/DLangDemangle.cpp
@@ -244,6 +244,55 @@
const char *Demangler::parseLName(OutputBuffer *Demangled, const char *Mangled,
unsigned long Len) {
+ switch (Len) {
+ case 6:
+ if (strncmp(Mangled, "__initZ", Len + 1) == 0) {
+ // The static initializer for a given symbol.
+ Demangled->prepend("initializer for ");
+ Demangled->setCurrentPosition(Demangled->getCurrentPosition() - 1);
+ Mangled += Len;
+ return Mangled;
+ }
+ if (strncmp(Mangled, "__vtblZ", Len + 1) == 0) {
+ // The vtable symbol for a given class.
+ Demangled->prepend("vtable for ");
+ Demangled->setCurrentPosition(Demangled->getCurrentPosition() - 1);
+ Mangled += Len;
+ return Mangled;
+ }
+ break;
+
+ case 7:
+ if (strncmp(Mangled, "__ClassZ", Len + 1) == 0) {
+ // The classinfo symbol for a given class.
+ Demangled->prepend("ClassInfo for ");
+ Demangled->setCurrentPosition(Demangled->getCurrentPosition() - 1);
+ Mangled += Len;
+ return Mangled;
+ }
+ break;
+
+ case 11:
+ if (strncmp(Mangled, "__InterfaceZ", Len + 1) == 0) {
+ // The interface symbol for a given class.
+ Demangled->prepend("Interface for ");
+ Demangled->setCurrentPosition(Demangled->getCurrentPosition() - 1);
+ Mangled += Len;
+ return Mangled;
+ }
+ break;
+
+ case 12:
+ if (strncmp(Mangled, "__ModuleInfoZ", Len + 1) == 0) {
+ // The ModuleInfo symbol for a given module.
+ Demangled->prepend("ModuleInfo for ");
+ Demangled->setCurrentPosition(Demangled->getCurrentPosition() - 1);
+ Mangled += Len;
+ return Mangled;
+ }
+ break;
+ }
+
*Demangled << StringView(Mangled, Len);
Mangled += Len;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114308.388680.patch
Type: text/x-patch
Size: 3113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211120/4c1b6423/attachment.bin>
More information about the llvm-commits
mailing list