[llvm] r350241 - [MS Demangler] Add a flag for dumping types without tag specifier.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 2 10:33:12 PST 2019
Author: zturner
Date: Wed Jan 2 10:33:12 2019
New Revision: 350241
URL: http://llvm.org/viewvc/llvm-project?rev=350241&view=rev
Log:
[MS Demangler] Add a flag for dumping types without tag specifier.
Sometimes it's useful to be able to output demangled names without
tag specifiers like "struct", "class", etc. This patch adds a
flag enabling this.
Modified:
llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h
llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
Modified: llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h?rev=350241&r1=350240&r2=350241&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h (original)
+++ llvm/trunk/include/llvm/Demangle/MicrosoftDemangleNodes.h Wed Jan 2 10:33:12 2019
@@ -53,6 +53,7 @@ enum class ReferenceKind : uint8_t { Non
enum OutputFlags {
OF_Default = 0,
OF_NoCallingConvention = 1,
+ OF_NoTagSpecifier = 2,
};
// Types
@@ -235,7 +236,7 @@ struct Node {
virtual void output(OutputStream &OS, OutputFlags Flags) const = 0;
- std::string toString() const;
+ std::string toString(OutputFlags Flags = OF_Default) const;
private:
NodeKind Kind;
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp?rev=350241&r1=350240&r2=350241&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp Wed Jan 2 10:33:12 2019
@@ -114,10 +114,10 @@ static void outputCallingConvention(Outp
}
}
-std::string Node::toString() const {
+std::string Node::toString(OutputFlags Flags) const {
OutputStream OS;
initializeOutputStream(nullptr, nullptr, OS, 1024);
- this->output(OS, llvm::ms_demangle::OF_Default);
+ this->output(OS, Flags);
OS << '\0';
return {OS.getBuffer()};
}
@@ -510,13 +510,15 @@ void PointerTypeNode::outputPost(OutputS
}
void TagTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
- switch (Tag) {
- OUTPUT_ENUM_CLASS_VALUE(TagKind, Class, "class");
- OUTPUT_ENUM_CLASS_VALUE(TagKind, Struct, "struct");
- OUTPUT_ENUM_CLASS_VALUE(TagKind, Union, "union");
- OUTPUT_ENUM_CLASS_VALUE(TagKind, Enum, "enum");
+ if (!(Flags & OF_NoTagSpecifier)) {
+ switch (Tag) {
+ OUTPUT_ENUM_CLASS_VALUE(TagKind, Class, "class");
+ OUTPUT_ENUM_CLASS_VALUE(TagKind, Struct, "struct");
+ OUTPUT_ENUM_CLASS_VALUE(TagKind, Union, "union");
+ OUTPUT_ENUM_CLASS_VALUE(TagKind, Enum, "enum");
+ }
+ OS << " ";
}
- OS << " ";
QualifiedName->output(OS, Flags);
outputQualifiers(OS, Quals, true, false);
}
More information about the llvm-commits
mailing list