AMDGPU: Don't handle invalid reg classes in helper functions
[oota-llvm.git] / tools / llvm-pdbdump / TypeDumper.cpp
index 8bca68e8d8b6f073f700dffabada18a036df6612..88c0bd65697ede96444d642076599aa037ee1550 100644 (file)
@@ -9,30 +9,32 @@
 
 #include "TypeDumper.h"
 
+#include "BuiltinDumper.h"
 #include "ClassDefinitionDumper.h"
+#include "EnumDumper.h"
 #include "LinePrinter.h"
 #include "llvm-pdbdump.h"
 #include "TypedefDumper.h"
 
 #include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
 
 using namespace llvm;
 
-TypeDumper::TypeDumper(LinePrinter &P, bool ClassDefs)
-    : PDBSymDumper(true), Printer(P), FullClassDefs(ClassDefs) {}
+TypeDumper::TypeDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
 
-void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
+void TypeDumper::start(const PDBSymbolExe &Exe) {
   auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
   Printer.NewLine();
   WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums";
   Printer << ": (" << Enums->getChildCount() << " items)";
   Printer.Indent();
   while (auto Enum = Enums->getNext())
-    Enum->dump(OS, Indent + 2, *this);
+    Enum->dump(*this);
   Printer.Unindent();
 
   auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
@@ -41,7 +43,7 @@ void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
   Printer << ": (" << Typedefs->getChildCount() << " items)";
   Printer.Indent();
   while (auto Typedef = Typedefs->getNext())
-    Typedef->dump(OS, Indent + 2, *this);
+    Typedef->dump(*this);
   Printer.Unindent();
 
   auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>();
@@ -50,34 +52,34 @@ void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
   Printer << ": (" << Classes->getChildCount() << " items)";
   Printer.Indent();
   while (auto Class = Classes->getNext())
-    Class->dump(OS, Indent + 2, *this);
+    Class->dump(*this);
   Printer.Unindent();
 }
 
-void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
-                      int Indent) {
+void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol) {
   if (Symbol.getUnmodifiedTypeId() != 0)
     return;
   if (Printer.IsTypeExcluded(Symbol.getName()))
     return;
-  Printer.NewLine();
+  // Dump member enums when dumping their class definition.
+  if (Symbol.isNested())
+    return;
 
-  WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
-  WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
+  Printer.NewLine();
+  EnumDumper Dumper(Printer);
+  Dumper.start(Symbol);
 }
 
-void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
-                      int Indent) {
+void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
   if (Printer.IsTypeExcluded(Symbol.getName()))
     return;
 
   Printer.NewLine();
   TypedefDumper Dumper(Printer);
-  Dumper.start(Symbol, OS, Indent);
+  Dumper.start(Symbol);
 }
 
-void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
-                      int Indent) {
+void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol) {
   if (Symbol.getUnmodifiedTypeId() != 0)
     return;
   if (Printer.IsTypeExcluded(Symbol.getName()))
@@ -85,11 +87,11 @@ void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
 
   Printer.NewLine();
 
-  if (FullClassDefs) {
-    ClassDefinitionDumper Dumper(Printer);
-    Dumper.start(Symbol, OS, Indent);
-  } else {
+  if (opts::NoClassDefs) {
     WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
     WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
+  } else {
+    ClassDefinitionDumper Dumper(Printer);
+    Dumper.start(Symbol);
   }
 }