summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/LinePrinter.cpp
diff options
context:
space:
mode:
authorAdrian McCarthy <amccarth@google.com>2017-03-23 15:28:15 +0000
committerAdrian McCarthy <amccarth@google.com>2017-03-23 15:28:15 +0000
commit1aa207d451d0f0a12ebfd8e841ca92be975fe1bc (patch)
tree7fb8708bfff6674a8a22fdb017c347d8190c9f1a /llvm/tools/llvm-pdbdump/LinePrinter.cpp
parenta8ba572dcfdb969fe1bb3381663298488891f838 (diff)
downloadbcm5719-llvm-1aa207d451d0f0a12ebfd8e841ca92be975fe1bc.tar.gz
bcm5719-llvm-1aa207d451d0f0a12ebfd8e841ca92be975fe1bc.zip
Add option to control whether llvm-pdbdump outputs in color
Adds -color-output option to llvm-pdbdump pretty commands that lets the user specify whether the output should have color. The default depends on whether the output is going to a TTY (per prior discussion in https://reviews.llvm.org/D31246). This will enable tests that pipe llvm-pdbdump output to FileCheck to work across platforms without regard to the differences in ANSI codes. Differential Revision: https://reviews.llvm.org/D31263 llvm-svn: 298610
Diffstat (limited to 'llvm/tools/llvm-pdbdump/LinePrinter.cpp')
-rw-r--r--llvm/tools/llvm-pdbdump/LinePrinter.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/tools/llvm-pdbdump/LinePrinter.cpp b/llvm/tools/llvm-pdbdump/LinePrinter.cpp
index 47c7d3e3c0e..14f8c78160f 100644
--- a/llvm/tools/llvm-pdbdump/LinePrinter.cpp
+++ b/llvm/tools/llvm-pdbdump/LinePrinter.cpp
@@ -42,8 +42,8 @@ bool IsItemExcluded(llvm::StringRef Item,
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 @@ bool LinePrinter::IsCompilandExcluded(llvm::StringRef CompilandName) {
}
WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) {
- applyColor(C);
+ if (P.hasColor())
+ applyColor(C);
}
WithColor::~WithColor() { OS.resetColor(); }
OpenPOWER on IntegriCloud