Mercurial > hg > CbC > CbC_llvm
comparison tools/llvm-pdbutil/PrettyEnumDumper.cpp @ 121:803732b1fca8
LLVM 5.0
author | kono |
---|---|
date | Fri, 27 Oct 2017 17:07:41 +0900 |
parents | |
children | c2174574ed3a |
comparison
equal
deleted
inserted
replaced
120:1172e4bd9c6f | 121:803732b1fca8 |
---|---|
1 //===- PrettyEnumDumper.cpp -------------------------------------*- 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 "PrettyEnumDumper.h" | |
11 | |
12 #include "LinePrinter.h" | |
13 #include "PrettyBuiltinDumper.h" | |
14 #include "llvm-pdbutil.h" | |
15 | |
16 #include "llvm/DebugInfo/PDB/PDBSymbolData.h" | |
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" | |
18 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" | |
19 | |
20 using namespace llvm; | |
21 using namespace llvm::pdb; | |
22 | |
23 EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {} | |
24 | |
25 void EnumDumper::start(const PDBSymbolTypeEnum &Symbol) { | |
26 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum "; | |
27 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName(); | |
28 if (!opts::pretty::NoEnumDefs) { | |
29 auto UnderlyingType = Symbol.getUnderlyingType(); | |
30 if (!UnderlyingType) | |
31 return; | |
32 if (UnderlyingType->getBuiltinType() != PDB_BuiltinType::Int || | |
33 UnderlyingType->getLength() != 4) { | |
34 Printer << " : "; | |
35 BuiltinDumper Dumper(Printer); | |
36 Dumper.start(*UnderlyingType); | |
37 } | |
38 auto EnumValues = Symbol.findAllChildren<PDBSymbolData>(); | |
39 Printer << " {"; | |
40 Printer.Indent(); | |
41 if (EnumValues && EnumValues->getChildCount() > 0) { | |
42 while (auto EnumValue = EnumValues->getNext()) { | |
43 if (EnumValue->getDataKind() != PDB_DataKind::Constant) | |
44 continue; | |
45 Printer.NewLine(); | |
46 WithColor(Printer, PDB_ColorItem::Identifier).get() | |
47 << EnumValue->getName(); | |
48 Printer << " = "; | |
49 WithColor(Printer, PDB_ColorItem::LiteralValue).get() | |
50 << EnumValue->getValue(); | |
51 } | |
52 } | |
53 Printer.Unindent(); | |
54 Printer.NewLine(); | |
55 Printer << "}"; | |
56 } | |
57 } |