[Demangle] Add a few more options to the microsoft demangler
This corresponds to commonly used options to UnDecorateSymbolName
within llvm.
Add them as hidden options in llvm-undname. MS undname.exe takes
numeric flags, corresponding to the UNDNAME_* constants, but instead
of hardcoding in mappings for those numbers, just add textual
options instead, as it the use of them here is primarily intended
for testing.
Differential Revision: https://reviews.llvm.org/D68917
llvm-svn: 374865
diff --git a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
index 10363dc..9cee975 100644
--- a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
@@ -378,24 +378,28 @@
void FunctionSignatureNode::outputPre(OutputStream &OS,
OutputFlags Flags) const {
- if (FunctionClass & FC_Public)
- OS << "public: ";
- if (FunctionClass & FC_Protected)
- OS << "protected: ";
- if (FunctionClass & FC_Private)
- OS << "private: ";
-
- if (!(FunctionClass & FC_Global)) {
- if (FunctionClass & FC_Static)
- OS << "static ";
+ if (!(Flags & OF_NoAccessSpecifier)) {
+ if (FunctionClass & FC_Public)
+ OS << "public: ";
+ if (FunctionClass & FC_Protected)
+ OS << "protected: ";
+ if (FunctionClass & FC_Private)
+ OS << "private: ";
}
- if (FunctionClass & FC_Virtual)
- OS << "virtual ";
- if (FunctionClass & FC_ExternC)
- OS << "extern \"C\" ";
+ if (!(Flags & OF_NoMemberType)) {
+ if (!(FunctionClass & FC_Global)) {
+ if (FunctionClass & FC_Static)
+ OS << "static ";
+ }
+ if (FunctionClass & FC_Virtual)
+ OS << "virtual ";
- if (ReturnType) {
+ if (FunctionClass & FC_ExternC)
+ OS << "extern \"C\" ";
+ }
+
+ if (!(Flags & OF_NoReturnType) && ReturnType) {
ReturnType->outputPre(OS, Flags);
OS << " ";
}
@@ -438,7 +442,7 @@
else if (RefQualifier == FunctionRefQualifier::RValueReference)
OS << " &&";
- if (ReturnType)
+ if (!(Flags & OF_NoReturnType) && ReturnType)
ReturnType->outputPost(OS, Flags);
}
@@ -580,19 +584,26 @@
}
void VariableSymbolNode::output(OutputStream &OS, OutputFlags Flags) const {
+ const char *AccessSpec = nullptr;
+ bool IsStatic = true;
switch (SC) {
case StorageClass::PrivateStatic:
- OS << "private: static ";
+ AccessSpec = "private";
break;
case StorageClass::PublicStatic:
- OS << "public: static ";
+ AccessSpec = "public";
break;
case StorageClass::ProtectedStatic:
- OS << "protected: static ";
+ AccessSpec = "protected";
break;
default:
+ IsStatic = false;
break;
}
+ if (!(Flags & OF_NoAccessSpecifier) && AccessSpec)
+ OS << AccessSpec << ": ";
+ if (!(Flags & OF_NoMemberType) && IsStatic)
+ OS << "static ";
if (Type) {
Type->outputPre(OS, Flags);