summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/VariableDumper.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-02-27 09:15:59 +0000
committerZachary Turner <zturner@google.com>2015-02-27 09:15:59 +0000
commit2d11c20445efe9ff69522e907e4be6b95c98eeba (patch)
treea3dfe22d414a500f00ca73551eea2e39359104b7 /llvm/tools/llvm-pdbdump/VariableDumper.cpp
parent44da5f64d25dfb2ee24064022cac620d7b59e772 (diff)
downloadbcm5719-llvm-2d11c20445efe9ff69522e907e4be6b95c98eeba.tar.gz
bcm5719-llvm-2d11c20445efe9ff69522e907e4be6b95c98eeba.zip
[llvm-pdbdump] Colorize output.
llvm-svn: 230746
Diffstat (limited to 'llvm/tools/llvm-pdbdump/VariableDumper.cpp')
-rw-r--r--llvm/tools/llvm-pdbdump/VariableDumper.cpp53
1 files changed, 32 insertions, 21 deletions
diff --git a/llvm/tools/llvm-pdbdump/VariableDumper.cpp b/llvm/tools/llvm-pdbdump/VariableDumper.cpp
index 371c270443a..90c418cf52a 100644
--- a/llvm/tools/llvm-pdbdump/VariableDumper.cpp
+++ b/llvm/tools/llvm-pdbdump/VariableDumper.cpp
@@ -10,6 +10,7 @@
#include "VariableDumper.h"
#include "BuiltinDumper.h"
+#include "LinePrinter.h"
#include "llvm-pdbdump.h"
#include "FunctionDumper.h"
@@ -26,45 +27,51 @@
using namespace llvm;
-VariableDumper::VariableDumper() : PDBSymDumper(true) {}
+VariableDumper::VariableDumper(LinePrinter &P)
+ : PDBSymDumper(true), Printer(P) {}
void VariableDumper::start(const PDBSymbolData &Var, raw_ostream &OS,
int Indent) {
- OS << newline(Indent);
- OS << "data ";
+ Printer.NewLine();
+ Printer << "data ";
auto VarType = Var.getType();
switch (auto LocType = Var.getLocationType()) {
case PDB_LocType::Static:
- OS << "[" << format_hex(Var.getRelativeVirtualAddress(), 10) << "] ";
- OS << "static ";
+ WithColor(Printer, PDB_ColorItem::Address).get()
+ << "[" << format_hex(Var.getRelativeVirtualAddress(), 10) << "] ";
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "static ";
dumpSymbolTypeAndName(*VarType, Var.getName(), OS);
break;
case PDB_LocType::Constant:
- OS << "const ";
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
dumpSymbolTypeAndName(*VarType, Var.getName(), OS);
- OS << "[" << Var.getValue() << "]";
+ Printer << "[";
+ WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Var.getValue();
+ Printer << "]";
break;
case PDB_LocType::ThisRel:
- OS << "+" << format_hex(Var.getOffset(), 4) << " ";
+ WithColor(Printer, PDB_ColorItem::Offset).get()
+ << "+" << format_hex(Var.getOffset(), 4) << " ";
dumpSymbolTypeAndName(*VarType, Var.getName(), OS);
break;
default:
+ OS << "unknown(" << LocType << ") ";
+ WithColor(Printer, PDB_ColorItem::Identifier).get() << Var.getName();
break;
- OS << "unknown(" << LocType << ") " << Var.getName();
}
}
void VariableDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
int Indent) {
- BuiltinDumper Dumper;
+ BuiltinDumper Dumper(Printer);
Dumper.start(Symbol, OS);
}
void VariableDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
int Indent) {
- OS << Symbol.getName();
+ WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
}
void VariableDumper::dump(const PDBSymbolTypeFunctionSig &Symbol,
@@ -77,29 +84,30 @@ void VariableDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
return;
if (auto Func = dyn_cast<PDBSymbolFunc>(PointeeType.get())) {
- FunctionDumper NestedDumper;
+ FunctionDumper NestedDumper(Printer);
FunctionDumper::PointerType Pointer =
Symbol.isReference() ? FunctionDumper::PointerType::Reference
: FunctionDumper::PointerType::Pointer;
NestedDumper.start(*Func, Pointer, OS, Indent);
} else {
if (Symbol.isConstType())
- OS << "const ";
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
if (Symbol.isVolatileType())
- OS << "volatile ";
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
PointeeType->dump(OS, Indent, *this);
- OS << (Symbol.isReference() ? "&" : "*");
+ Printer << (Symbol.isReference() ? "&" : "*");
}
}
void VariableDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
int Indent) {
- OS << "typedef " << Symbol.getName();
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "typedef ";
+ WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
}
void VariableDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
int Indent) {
- OS << Symbol.getName();
+ WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
}
void VariableDumper::dumpSymbolTypeAndName(const PDBSymbol &Type,
@@ -109,16 +117,19 @@ void VariableDumper::dumpSymbolTypeAndName(const PDBSymbol &Type,
raw_string_ostream IndexStream(IndexSpec);
std::unique_ptr<PDBSymbol> ElementType = ArrayType->getElementType();
while (auto NestedArray = dyn_cast<PDBSymbolTypeArray>(ElementType.get())) {
- IndexStream << "[" << NestedArray->getCount() << "]";
+ IndexStream << "[";
+ IndexStream << NestedArray->getCount();
+ IndexStream << "]";
ElementType = NestedArray->getElementType();
}
IndexStream << "[" << ArrayType->getCount() << "]";
ElementType->dump(OS, 0, *this);
- OS << " " << Name << IndexStream.str();
+ WithColor(Printer, PDB_ColorItem::Identifier).get() << " " << Name;
+ Printer << IndexStream.str();
} else {
if (!tryDumpFunctionPointer(Type, Name, OS)) {
Type.dump(OS, 0, *this);
- OS << " " << Name;
+ WithColor(Printer, PDB_ColorItem::Identifier).get() << " " << Name;
}
}
}
@@ -131,7 +142,7 @@ bool VariableDumper::tryDumpFunctionPointer(const PDBSymbol &Type,
auto PointeeType = PointerType->getPointeeType();
if (auto *FunctionSig =
dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
- FunctionDumper Dumper;
+ FunctionDumper Dumper(Printer);
FunctionDumper::PointerType PT = FunctionDumper::PointerType::Pointer;
if (PointerType->isReference())
PT = FunctionDumper::PointerType::Reference;
OpenPOWER on IntegriCloud