1 //===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "TypeDumper.h"
12 #include "BuiltinDumper.h"
13 #include "ClassDefinitionDumper.h"
14 #include "EnumDumper.h"
15 #include "LinePrinter.h"
16 #include "llvm-pdbdump.h"
17 #include "TypedefDumper.h"
19 #include "llvm/DebugInfo/PDB/IPDBSession.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
27 using namespace llvm::pdb;
29 TypeDumper::TypeDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
31 void TypeDumper::start(const PDBSymbolExe &Exe) {
32 auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
34 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums";
35 Printer << ": (" << Enums->getChildCount() << " items)";
37 while (auto Enum = Enums->getNext())
41 auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
43 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs";
44 Printer << ": (" << Typedefs->getChildCount() << " items)";
46 while (auto Typedef = Typedefs->getNext())
50 auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>();
52 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Classes";
53 Printer << ": (" << Classes->getChildCount() << " items)";
55 while (auto Class = Classes->getNext())
60 void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol) {
61 if (Symbol.getUnmodifiedTypeId() != 0)
63 if (Printer.IsTypeExcluded(Symbol.getName()))
65 // Dump member enums when dumping their class definition.
66 if (nullptr != Symbol.getClassParent())
70 EnumDumper Dumper(Printer);
74 void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
75 if (Printer.IsTypeExcluded(Symbol.getName()))
79 TypedefDumper Dumper(Printer);
83 void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol) {
84 if (Symbol.getUnmodifiedTypeId() != 0)
86 if (Printer.IsTypeExcluded(Symbol.getName()))
91 if (opts::pretty::NoClassDefs) {
92 WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
93 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
95 ClassDefinitionDumper Dumper(Printer);