[llvm-pdbdump] Colorize output.
[oota-llvm.git] / tools / llvm-pdbdump / ClassDefinitionDumper.h
1 //===- ClassDefinitionDumper.h - --------------------------------*- 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 #ifndef LLVM_TOOLS_LLVMPDBDUMP_CLASSDEFINITIONDUMPER_H
11 #define LLVM_TOOLS_LLVMPDBDUMP_CLASSDEFINITIONDUMPER_H
12
13 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
16
17 #include <list>
18 #include <memory>
19 #include <unordered_map>
20
21 namespace llvm {
22
23 class LinePrinter;
24
25 class ClassDefinitionDumper : public PDBSymDumper {
26 public:
27   ClassDefinitionDumper(LinePrinter &P);
28
29   void start(const PDBSymbolTypeUDT &Exe, raw_ostream &OS, int Indent);
30
31   void dump(const PDBSymbolTypeBaseClass &Symbol, raw_ostream &OS,
32             int Indent) override;
33   void dump(const PDBSymbolData &Symbol, raw_ostream &OS, int Indent) override;
34   void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
35             int Indent) override;
36   void dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent) override;
37   void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
38             int Indent) override;
39   void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
40             int Indent) override;
41   void dump(const PDBSymbolTypeVTable &Symbol, raw_ostream &OS,
42             int Indent) override;
43
44 private:
45   LinePrinter &Printer;
46
47   struct SymbolGroup {
48     SymbolGroup() {}
49     SymbolGroup(SymbolGroup &&Other) {
50       Functions = std::move(Other.Functions);
51       Data = std::move(Other.Data);
52       Unknown = std::move(Other.Unknown);
53     }
54
55     std::list<std::unique_ptr<PDBSymbolFunc>> Functions;
56     std::list<std::unique_ptr<PDBSymbolData>> Data;
57     std::list<std::unique_ptr<PDBSymbol>> Unknown;
58     SymbolGroup(const SymbolGroup &other) = delete;
59     SymbolGroup &operator=(const SymbolGroup &other) = delete;
60   };
61   typedef std::unordered_map<int, SymbolGroup> SymbolGroupByAccess;
62
63   int dumpAccessGroup(PDB_MemberAccess Access, const SymbolGroup &Group,
64                       raw_ostream &OS, int Indent);
65 };
66 }
67
68 #endif