1//===- EnumDumper.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 "EnumDumper.h" 11 12#include "BuiltinDumper.h" 13#include "LinePrinter.h" 14#include "llvm-pdbdump.h" 15 16#include "llvm/DebugInfo/PDB/PDBSymbolData.h" 17#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" 18#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" 19 20using namespace llvm; 21 22EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {} 23 24void 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) { 31 Printer << " : "; 32 BuiltinDumper Dumper(Printer); 33 Dumper.start(*BuiltinType); 34 } 35 Printer << " {"; 36 Printer.Indent(); 37 auto EnumValues = Symbol.findAllChildren<PDBSymbolData>(); 38 while (auto EnumValue = EnumValues->getNext()) { 39 if (EnumValue->getDataKind() != PDB_DataKind::Constant) 40 continue; 41 Printer.NewLine(); 42 WithColor(Printer, PDB_ColorItem::Identifier).get() 43 << EnumValue->getName(); 44 Printer << " = "; 45 WithColor(Printer, PDB_ColorItem::LiteralValue).get() 46 << EnumValue->getValue(); 47 } 48 Printer.Unindent(); 49 Printer.NewLine(); 50 Printer << "}"; 51 } 52} 53