[uselistorder] Insert blank line, NFC
[oota-llvm.git] / tools / llvm-pdbdump / TypedefDumper.cpp
index 55fcb1a3ade86637b9ce64839797d39d506d592e..a6b5c53a6b3a939bef11f313ec1bbfa12f812747 100644 (file)
@@ -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"
 
 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:" << Symbol.getName() << " -> ";
+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);
+    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)
@@ -63,22 +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);
-    OS.flush();
+    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();
 }