diff options
| author | Adrian McCarthy <amccarth@google.com> | 2017-03-23 15:28:15 +0000 |
|---|---|---|
| committer | Adrian McCarthy <amccarth@google.com> | 2017-03-23 15:28:15 +0000 |
| commit | 1aa207d451d0f0a12ebfd8e841ca92be975fe1bc (patch) | |
| tree | 7fb8708bfff6674a8a22fdb017c347d8190c9f1a /llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | |
| parent | a8ba572dcfdb969fe1bb3381663298488891f838 (diff) | |
| download | bcm5719-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/llvm-pdbdump.cpp')
| -rw-r--r-- | llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index 8b166411f0b..3bd5fd7273b 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -125,8 +125,11 @@ cl::opt<uint64_t> LoadAddress( 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 @@ static void dumpPretty(StringRef Path) { 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()); |

