[PATCH] D31263: Add option to control whether llvm-pdbdump outputs in color
Adrian McCarthy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 23 08:40:33 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298610: Add option to control whether llvm-pdbdump outputs in color (authored by amccarth).
Changed prior to commit:
https://reviews.llvm.org/D31263?vs=92719&id=92807#toc
Repository:
rL LLVM
https://reviews.llvm.org/D31263
Files:
llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp
llvm/trunk/tools/llvm-pdbdump/LinePrinter.h
llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
Index: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
===================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -125,8 +125,11 @@
cl::desc("Assume the module is loaded at the specified address"),
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::opt<bool> Native("native", cl::desc("Use native PDB reader instead of DIA"),
- cl::cat(OtherOptions), cl::sub(PrettySubcommand));
-
+ cl::cat(OtherOptions), cl::sub(PrettySubcommand));
+cl::opt<cl::boolOrDefault>
+ ColorOutput("color-output",
+ cl::desc("Override use of color (default = isatty)"),
+ cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::list<std::string> ExcludeTypes(
"exclude-types", cl::desc("Exclude types by regular expression"),
cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
@@ -500,7 +503,11 @@
if (opts::pretty::LoadAddress)
Session->setLoadAddress(opts::pretty::LoadAddress);
- LinePrinter Printer(2, outs());
+ auto &Stream = outs();
+ const bool UseColor = opts::pretty::ColorOutput == cl::BOU_UNSET
+ ? Stream.has_colors()
+ : opts::pretty::ColorOutput == cl::BOU_TRUE;
+ LinePrinter Printer(2, UseColor, Stream);
auto GlobalScope(Session->getGlobalScope());
std::string FileName(GlobalScope->getSymbolsFileName());
Index: llvm/trunk/tools/llvm-pdbdump/LinePrinter.h
===================================================================
--- llvm/trunk/tools/llvm-pdbdump/LinePrinter.h
+++ llvm/trunk/tools/llvm-pdbdump/LinePrinter.h
@@ -24,12 +24,13 @@
friend class WithColor;
public:
- LinePrinter(int Indent, raw_ostream &Stream);
+ LinePrinter(int Indent, bool UseColor, raw_ostream &Stream);
void Indent();
void Unindent();
void NewLine();
+ bool hasColor() const { return UseColor; }
raw_ostream &getStream() { return OS; }
int getIndentLevel() const { return CurrentIndent; }
@@ -48,6 +49,7 @@
raw_ostream &OS;
int IndentSpaces;
int CurrentIndent;
+ bool UseColor;
std::list<Regex> ExcludeCompilandFilters;
std::list<Regex> ExcludeTypeFilters;
Index: llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp
===================================================================
--- llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp
+++ llvm/trunk/tools/llvm-pdbdump/LinePrinter.cpp
@@ -42,8 +42,8 @@
using namespace llvm;
-LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
- : OS(Stream), IndentSpaces(Indent), CurrentIndent(0) {
+LinePrinter::LinePrinter(int Indent, bool UseColor, llvm::raw_ostream &Stream)
+ : OS(Stream), IndentSpaces(Indent), CurrentIndent(0), UseColor(UseColor) {
SetFilters(ExcludeTypeFilters, opts::pretty::ExcludeTypes.begin(),
opts::pretty::ExcludeTypes.end());
SetFilters(ExcludeSymbolFilters, opts::pretty::ExcludeSymbols.begin(),
@@ -84,7 +84,8 @@
}
WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) {
- applyColor(C);
+ if (P.hasColor())
+ applyColor(C);
}
WithColor::~WithColor() { OS.resetColor(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31263.92807.patch
Type: text/x-patch
Size: 3213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170323/33a7bc87/attachment.bin>
More information about the llvm-commits
mailing list