llvm.org GIT mirror llvm / ed72a64
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350241 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 8 months ago
2 changed file(s) with 13 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
5252 enum OutputFlags {
5353 OF_Default = 0,
5454 OF_NoCallingConvention = 1,
55 OF_NoTagSpecifier = 2,
5556 };
5657
5758 // Types
234235
235236 virtual void output(OutputStream &OS, OutputFlags Flags) const = 0;
236237
237 std::string toString() const;
238 std::string toString(OutputFlags Flags = OF_Default) const;
238239
239240 private:
240241 NodeKind Kind;
113113 }
114114 }
115115
116 std::string Node::toString() const {
116 std::string Node::toString(OutputFlags Flags) const {
117117 OutputStream OS;
118118 initializeOutputStream(nullptr, nullptr, OS, 1024);
119 this->output(OS, llvm::ms_demangle::OF_Default);
119 this->output(OS, Flags);
120120 OS << '\0';
121121 return {OS.getBuffer()};
122122 }
509509 }
510510
511511 void TagTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {
512 switch (Tag) {
513 OUTPUT_ENUM_CLASS_VALUE(TagKind, Class, "class");
514 OUTPUT_ENUM_CLASS_VALUE(TagKind, Struct, "struct");
515 OUTPUT_ENUM_CLASS_VALUE(TagKind, Union, "union");
516 OUTPUT_ENUM_CLASS_VALUE(TagKind, Enum, "enum");
517 }
518 OS << " ";
512 if (!(Flags & OF_NoTagSpecifier)) {
513 switch (Tag) {
514 OUTPUT_ENUM_CLASS_VALUE(TagKind, Class, "class");
515 OUTPUT_ENUM_CLASS_VALUE(TagKind, Struct, "struct");
516 OUTPUT_ENUM_CLASS_VALUE(TagKind, Union, "union");
517 OUTPUT_ENUM_CLASS_VALUE(TagKind, Enum, "enum");
518 }
519 OS << " ";
520 }
519521 QualifiedName->output(OS, Flags);
520522 outputQualifiers(OS, Quals, true, false);
521523 }