1 //===- EnumDumper.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 "EnumDumper.h"
12 #include "BuiltinDumper.h"
13 #include "LinePrinter.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"
22 EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
24 void EnumDumper::start(const PDBSymbolTypeEnum &Symbol) {
25 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
26 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
27 if (!opts::NoEnumDefs) {
28 auto BuiltinType = Symbol.getUnderlyingType();
29 if (BuiltinType->getBuiltinType() != PDB_BuiltinType::Int ||
30 BuiltinType->getLength() != 4) {
32 BuiltinDumper Dumper(Printer);
33 Dumper.start(*BuiltinType);
37 auto EnumValues = Symbol.findAllChildren<PDBSymbolData>();
38 while (auto EnumValue = EnumValues->getNext()) {
39 if (EnumValue->getDataKind() != PDB_DataKind::Constant)
42 WithColor(Printer, PDB_ColorItem::Identifier).get()
43 << EnumValue->getName();
45 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
46 << EnumValue->getValue();