72171b0f318808a3095275f2750a34b9ba232469
[oota-llvm.git] / tools / llvm-pdbdump / TypeDumper.cpp
1 //===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "TypeDumper.h"
11
12 #include "FunctionDumper.h"
13 #include "llvm-pdbdump.h"
14 #include "TypedefDumper.h"
15
16 #include "llvm/DebugInfo/PDB/IPDBSession.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
21
22 using namespace llvm;
23
24 TypeDumper::TypeDumper() : PDBSymDumper(true) {}
25
26 void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
27   auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
28   OS << newline(Indent) << "Enums: (" << Enums->getChildCount() << " items)";
29   while (auto Enum = Enums->getNext())
30     Enum->dump(OS, Indent + 2, *this);
31
32   auto FuncSigs = Exe.findAllChildren<PDBSymbolTypeFunctionSig>();
33   OS << newline(Indent);
34   OS << "Function Signatures: (" << FuncSigs->getChildCount() << " items)";
35   while (auto Sig = FuncSigs->getNext())
36     Sig->dump(OS, Indent + 2, *this);
37
38   auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
39   OS << newline(Indent) << "Typedefs: (" << Typedefs->getChildCount()
40      << " items)";
41   while (auto Typedef = Typedefs->getNext())
42     Typedef->dump(OS, Indent + 2, *this);
43 }
44
45 void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
46                       int Indent) {
47   OS << newline(Indent) << "enum " << Symbol.getName();
48 }
49
50 void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
51                       int Indent) {
52   OS << newline(Indent);
53   FunctionDumper Dumper;
54   Dumper.start(Symbol, FunctionDumper::PointerType::None, OS);
55 }
56
57 void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
58                       int Indent) {
59   OS << newline(Indent);
60   TypedefDumper Dumper;
61   Dumper.start(Symbol, OS, Indent);
62   OS.flush();
63 }