[llvm] 8a7ddf9 - [Demangle] Add support for D special identifiers
Luís Ferreira via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 17:48:41 PST 2021
Author: Luís Ferreira
Date: 2021-12-07T01:46:08Z
New Revision: 8a7ddf9e2296c2b188c49f689ea51eab6114a662
URL: https://github.com/llvm/llvm-project/commit/8a7ddf9e2296c2b188c49f689ea51eab6114a662
DIFF: https://github.com/llvm/llvm-project/commit/8a7ddf9e2296c2b188c49f689ea51eab6114a662.diff
LOG: [Demangle] Add support for D special identifiers
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D114308
Added:
Modified:
llvm/lib/Demangle/DLangDemangle.cpp
llvm/unittests/Demangle/DLangDemangleTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Demangle/DLangDemangle.cpp b/llvm/lib/Demangle/DLangDemangle.cpp
index f380aa90035e5..86f7412067d64 100644
--- a/llvm/lib/Demangle/DLangDemangle.cpp
+++ b/llvm/lib/Demangle/DLangDemangle.cpp
@@ -247,6 +247,55 @@ const char *Demangler::parseIdentifier(OutputBuffer *Demangled,
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;
diff --git a/llvm/unittests/Demangle/DLangDemangleTest.cpp b/llvm/unittests/Demangle/DLangDemangleTest.cpp
index a3123601661ba..e1904d4435c19 100644
--- a/llvm/unittests/Demangle/DLangDemangleTest.cpp
+++ b/llvm/unittests/Demangle/DLangDemangleTest.cpp
@@ -36,4 +36,13 @@ INSTANTIATE_TEST_SUITE_P(
std::make_pair("_D8demangle4testZ", "demangle.test"),
std::make_pair("_D8demangle4test5test2Z", "demangle.test.test2"),
std::make_pair("_D8demangle4test0Z", "demangle.test"),
- std::make_pair("_D8demangle4test03fooZ", "demangle.test.foo")));
+ std::make_pair("_D8demangle4test03fooZ", "demangle.test.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")));
More information about the llvm-commits
mailing list