summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-06-09 20:46:17 +0000
committerZachary Turner <zturner@google.com>2017-06-09 20:46:17 +0000
commitbd336e44d8ab60e0c1d7ef7703ba0ff5c51e43b5 (patch)
treef5e0c55de301a14315293533cd49afb31999d838 /llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp
parente22b6969363d78bb2fb2d3c0778c2dbbcfaabcde (diff)
downloadbcm5719-llvm-bd336e44d8ab60e0c1d7ef7703ba0ff5c51e43b5.tar.gz
bcm5719-llvm-bd336e44d8ab60e0c1d7ef7703ba0ff5c51e43b5.zip
Rename llvm-pdbdump -> llvm-pdbutil.
This is to reflect the evolving nature of the tool as being useful for more than just dumping PDBs, as it can do many other things. Differential Revision: https://reviews.llvm.org/D34062 llvm-svn: 305106
Diffstat (limited to 'llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp')
-rw-r--r--llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp b/llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp
new file mode 100644
index 00000000000..7aff5b93d98
--- /dev/null
+++ b/llvm/tools/llvm-pdbutil/PrettyEnumDumper.cpp
@@ -0,0 +1,53 @@
+//===- PrettyEnumDumper.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PrettyEnumDumper.h"
+
+#include "LinePrinter.h"
+#include "PrettyBuiltinDumper.h"
+#include "llvm-pdbutil.h"
+
+#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
+
+using namespace llvm;
+using namespace llvm::pdb;
+
+EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
+
+void EnumDumper::start(const PDBSymbolTypeEnum &Symbol) {
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
+ WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
+ if (!opts::pretty::NoEnumDefs) {
+ auto BuiltinType = Symbol.getUnderlyingType();
+ if (BuiltinType->getBuiltinType() != PDB_BuiltinType::Int ||
+ BuiltinType->getLength() != 4) {
+ Printer << " : ";
+ BuiltinDumper Dumper(Printer);
+ Dumper.start(*BuiltinType);
+ }
+ Printer << " {";
+ Printer.Indent();
+ auto EnumValues = Symbol.findAllChildren<PDBSymbolData>();
+ while (auto EnumValue = EnumValues->getNext()) {
+ if (EnumValue->getDataKind() != PDB_DataKind::Constant)
+ continue;
+ Printer.NewLine();
+ WithColor(Printer, PDB_ColorItem::Identifier).get()
+ << EnumValue->getName();
+ Printer << " = ";
+ WithColor(Printer, PDB_ColorItem::LiteralValue).get()
+ << EnumValue->getValue();
+ }
+ Printer.Unindent();
+ Printer.NewLine();
+ Printer << "}";
+ }
+}
OpenPOWER on IntegriCloud