2017-01-11 01:35:43 +01:00
|
|
|
//===- PrettyEnumDumper.cpp -------------------------------------*- C++ -*-===//
|
2015-03-04 07:09:53 +01:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-03-04 07:09:53 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-01-11 01:35:43 +01:00
|
|
|
#include "PrettyEnumDumper.h"
|
2015-03-04 07:09:53 +01:00
|
|
|
|
|
|
|
#include "LinePrinter.h"
|
2017-01-11 01:35:43 +01:00
|
|
|
#include "PrettyBuiltinDumper.h"
|
2017-06-09 22:46:17 +02:00
|
|
|
#include "llvm-pdbutil.h"
|
2015-03-04 07:09:53 +01:00
|
|
|
|
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
|
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
|
|
|
|
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
2016-05-04 22:32:13 +02:00
|
|
|
using namespace llvm::pdb;
|
2015-03-04 07:09:53 +01:00
|
|
|
|
|
|
|
EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
|
|
|
|
|
|
|
|
void EnumDumper::start(const PDBSymbolTypeEnum &Symbol) {
|
2018-09-15 00:29:19 +02:00
|
|
|
if (Symbol.getUnmodifiedTypeId() != 0) {
|
|
|
|
if (Symbol.isConstType())
|
|
|
|
WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
|
|
|
|
if (Symbol.isVolatileType())
|
|
|
|
WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
|
|
|
|
if (Symbol.isUnalignedType())
|
|
|
|
WithColor(Printer, PDB_ColorItem::Keyword).get() << "unaligned ";
|
|
|
|
WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
|
|
|
|
WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-04 07:09:53 +01:00
|
|
|
WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
|
|
|
|
WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
|
2016-06-30 19:42:48 +02:00
|
|
|
if (!opts::pretty::NoEnumDefs) {
|
2017-08-05 00:37:58 +02:00
|
|
|
auto UnderlyingType = Symbol.getUnderlyingType();
|
|
|
|
if (!UnderlyingType)
|
|
|
|
return;
|
|
|
|
if (UnderlyingType->getBuiltinType() != PDB_BuiltinType::Int ||
|
|
|
|
UnderlyingType->getLength() != 4) {
|
2015-03-04 07:09:53 +01:00
|
|
|
Printer << " : ";
|
|
|
|
BuiltinDumper Dumper(Printer);
|
2017-08-05 00:37:58 +02:00
|
|
|
Dumper.start(*UnderlyingType);
|
2015-03-04 07:09:53 +01:00
|
|
|
}
|
2017-08-05 00:37:58 +02:00
|
|
|
auto EnumValues = Symbol.findAllChildren<PDBSymbolData>();
|
2015-03-04 07:09:53 +01:00
|
|
|
Printer << " {";
|
|
|
|
Printer.Indent();
|
2017-08-05 00:37:58 +02:00
|
|
|
if (EnumValues && EnumValues->getChildCount() > 0) {
|
|
|
|
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();
|
|
|
|
}
|
2015-03-04 07:09:53 +01:00
|
|
|
}
|
|
|
|
Printer.Unindent();
|
|
|
|
Printer.NewLine();
|
|
|
|
Printer << "}";
|
|
|
|
}
|
|
|
|
}
|