OSDN Git Service

Update aosp/master LLVM for rebase to r230699.
[android-x86/external-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 "ClassDefinitionDumper.h"
13 #include "FunctionDumper.h"
14 #include "llvm-pdbdump.h"
15 #include "TypedefDumper.h"
16
17 #include "llvm/DebugInfo/PDB/IPDBSession.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
23
24 using namespace llvm;
25
26 TypeDumper::TypeDumper(bool Inline, bool ClassDefs)
27     : PDBSymDumper(true), InlineDump(Inline), FullClassDefs(ClassDefs) {}
28
29 void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
30   auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
31   OS << newline(Indent) << "Enums: (" << Enums->getChildCount() << " items)";
32   while (auto Enum = Enums->getNext())
33     Enum->dump(OS, Indent + 2, *this);
34
35   auto FuncSigs = Exe.findAllChildren<PDBSymbolTypeFunctionSig>();
36   OS << newline(Indent);
37   OS << "Function Signatures: (" << FuncSigs->getChildCount() << " items)";
38   while (auto Sig = FuncSigs->getNext())
39     Sig->dump(OS, Indent + 2, *this);
40
41   auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
42   OS << newline(Indent) << "Typedefs: (" << Typedefs->getChildCount()
43      << " items)";
44   while (auto Typedef = Typedefs->getNext())
45     Typedef->dump(OS, Indent + 2, *this);
46
47   auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>();
48   OS << newline(Indent) << "Classes: (" << Classes->getChildCount()
49      << " items)";
50   while (auto Class = Classes->getNext())
51     Class->dump(OS, Indent + 2, *this);
52 }
53
54 void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
55                       int Indent) {
56   if (Symbol.getUnmodifiedTypeId() != 0)
57     return;
58
59   if (!InlineDump)
60     OS << newline(Indent);
61
62   OS << "enum " << Symbol.getName();
63 }
64
65 void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
66                       int Indent) {
67   if (!InlineDump)
68     OS << newline(Indent);
69
70   FunctionDumper Dumper;
71   Dumper.start(Symbol, FunctionDumper::PointerType::None, OS);
72 }
73
74 void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
75                       int Indent) {
76   if (!InlineDump)
77     OS << newline(Indent);
78
79   TypedefDumper Dumper;
80   Dumper.start(Symbol, OS, Indent);
81 }
82
83 void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
84                       int Indent) {
85   if (Symbol.getUnmodifiedTypeId() != 0)
86     return;
87   if (!InlineDump)
88     OS << newline(Indent);
89
90   if (FullClassDefs) {
91     ClassDefinitionDumper Dumper;
92     Dumper.start(Symbol, OS, Indent);
93   } else {
94     OS << "class " << Symbol.getName();
95   }
96 }