X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-pdbdump%2FTypedefDumper.cpp;h=a6b5c53a6b3a939bef11f313ec1bbfa12f812747;hb=3f1d2f9e7863ced5221b1c5afef80ac7aa6bd479;hp=6eea6b69d95ae8a59ade681d498530d849f6d9ff;hpb=4ad658d8f13aa81c59bf7f6ab8210417d7b5fe39;p=oota-llvm.git diff --git a/tools/llvm-pdbdump/TypedefDumper.cpp b/tools/llvm-pdbdump/TypedefDumper.cpp index 6eea6b69d95..a6b5c53a6b3 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(); }