1 //===- PrettyEnumDumper.cpp -------------------------------------*- 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 "PrettyEnumDumper.h"
12 #include "LinePrinter.h"
13 #include "PrettyBuiltinDumper.h"
14 #include "llvm-pdbdump.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
21 using namespace llvm::pdb;
23 EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
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 BuiltinType = Symbol.getUnderlyingType();
30 if (BuiltinType->getBuiltinType() != PDB_BuiltinType::Int ||
31 BuiltinType->getLength() != 4) {
33 BuiltinDumper Dumper(Printer);
34 Dumper.start(*BuiltinType);
38 auto EnumValues = Symbol.findAllChildren<PDBSymbolData>();
39 while (auto EnumValue = EnumValues->getNext()) {
40 if (EnumValue->getDataKind() != PDB_DataKind::Constant)
43 WithColor(Printer, PDB_ColorItem::Identifier).get()
44 << EnumValue->getName();
46 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
47 << EnumValue->getValue();