diff options
Diffstat (limited to 'tools/llvm-pdbdump/TypedefDumper.cpp')
-rw-r--r-- | tools/llvm-pdbdump/TypedefDumper.cpp | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/tools/llvm-pdbdump/TypedefDumper.cpp b/tools/llvm-pdbdump/TypedefDumper.cpp index 6eea6b6..a6b5c53 100644 --- a/tools/llvm-pdbdump/TypedefDumper.cpp +++ b/tools/llvm-pdbdump/TypedefDumper.cpp @@ -9,12 +9,13 @@ #include "TypedefDumper.h" +#include "BuiltinDumper.h" #include "FunctionDumper.h" +#include "LinePrinter.h" #include "llvm-pdbdump.h" #include "llvm/DebugInfo/PDB/IPDBSession.h" #include "llvm/DebugInfo/PDB/PDBExtras.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h" @@ -23,39 +24,34 @@ using namespace llvm; -TypedefDumper::TypedefDumper() : PDBSymDumper(true) {} +TypedefDumper::TypedefDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {} -void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS, - int Indent) { - OS << "typedef "; +void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol) { + WithColor(Printer, PDB_ColorItem::Keyword).get() << "typedef "; uint32_t TargetId = Symbol.getTypeId(); if (auto TypeSymbol = Symbol.getSession().getSymbolById(TargetId)) - TypeSymbol->dump(OS, 0, *this); - OS << " " << Symbol.getName(); + TypeSymbol->dump(*this); + WithColor(Printer, PDB_ColorItem::Identifier).get() << " " + << Symbol.getName(); } -void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS, - int Indent) {} +void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol) {} -void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS, - int Indent) { - PDB_BuiltinType Type = Symbol.getBuiltinType(); - OS << Type; - if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int) - OS << (8 * Symbol.getLength()) << "_t"; +void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol) { + BuiltinDumper Dumper(Printer); + Dumper.start(Symbol); } -void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS, - int Indent) { - OS << "enum " << Symbol.getName(); +void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol) { + WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum "; + WithColor(Printer, PDB_ColorItem::Type).get() << " " << Symbol.getName(); } -void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS, - int Indent) { +void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol) { if (Symbol.isConstType()) - OS << "const "; + WithColor(Printer, PDB_ColorItem::Keyword).get() << "const "; if (Symbol.isVolatileType()) - OS << "volatile "; + WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile "; uint32_t PointeeId = Symbol.getTypeId(); auto PointeeType = Symbol.getSession().getSymbolById(PointeeId); if (!PointeeType) @@ -64,21 +60,20 @@ void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS, FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer; if (Symbol.isReference()) Pointer = FunctionDumper::PointerType::Reference; - FunctionDumper NestedDumper; - NestedDumper.start(*FuncSig, Pointer, OS); + FunctionDumper NestedDumper(Printer); + NestedDumper.start(*FuncSig, nullptr, Pointer); } else { - PointeeType->dump(OS, Indent, *this); - OS << ((Symbol.isReference()) ? "&" : "*"); + PointeeType->dump(*this); + Printer << ((Symbol.isReference()) ? "&" : "*"); } } -void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, - raw_ostream &OS, int Indent) { - FunctionDumper Dumper; - Dumper.start(Symbol, FunctionDumper::PointerType::None, OS); +void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) { + FunctionDumper Dumper(Printer); + Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None); } -void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS, - int Indent) { - OS << "class " << Symbol.getName(); +void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol) { + WithColor(Printer, PDB_ColorItem::Keyword).get() << "class "; + WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName(); } |