mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
llvm-cov: Only emit colour by default if the output is a tty
This replaces the -no-color flag with a -color={auto|always|never} option, with auto as the default, which is much saner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/PrettyStackTrace.h"
|
||||
#include "llvm/Support/Process.h"
|
||||
#include "llvm/Support/Signals.h"
|
||||
#include <functional>
|
||||
#include <system_error>
|
||||
@@ -293,11 +294,24 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
|
||||
"greater than the given threshold"),
|
||||
cl::cat(FilteringCategory));
|
||||
|
||||
enum class Colors { Auto, Always, Never };
|
||||
cl::opt<Colors> Color(
|
||||
"color", cl::desc("Configure color output:"),
|
||||
cl::values(clEnumValN(Colors::Auto, "auto",
|
||||
"Enable color if stdout seems to support it"),
|
||||
clEnumValN(Colors::Always, "always", "Enable color"),
|
||||
clEnumValN(Colors::Never, "never", "Disable color"),
|
||||
clEnumValEnd));
|
||||
|
||||
auto commandLineParser = [&, this](int argc, const char **argv) -> int {
|
||||
cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n");
|
||||
ViewOpts.Debug = DebugDump;
|
||||
CompareFilenamesOnly = FilenameEquivalence;
|
||||
|
||||
ViewOpts.Colors =
|
||||
Color == Colors::Always ||
|
||||
(Color == Colors::Auto && sys::Process::StandardOutHasColors());
|
||||
|
||||
// Create the function filters
|
||||
if (!NameFilters.empty() || !NameRegexFilters.empty()) {
|
||||
auto NameFilterer = new CoverageFilters;
|
||||
@@ -388,15 +402,10 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
cl::desc("Show function instantiations"),
|
||||
cl::cat(ViewCategory));
|
||||
|
||||
cl::opt<bool> NoColors("no-colors", cl::Optional,
|
||||
cl::desc("Don't show text colors"), cl::init(false),
|
||||
cl::cat(ViewCategory));
|
||||
|
||||
auto Err = commandLineParser(argc, argv);
|
||||
if (Err)
|
||||
return Err;
|
||||
|
||||
ViewOpts.Colors = !NoColors;
|
||||
ViewOpts.ShowLineNumbers = true;
|
||||
ViewOpts.ShowLineStats = ShowLineExecutionCounts.getNumOccurrences() != 0 ||
|
||||
!ShowRegions || ShowBestLineRegionsCounts;
|
||||
@@ -462,15 +471,10 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
|
||||
int CodeCoverageTool::report(int argc, const char **argv,
|
||||
CommandLineParserType commandLineParser) {
|
||||
cl::opt<bool> NoColors("no-colors", cl::Optional,
|
||||
cl::desc("Don't show text colors"), cl::init(false));
|
||||
|
||||
auto Err = commandLineParser(argc, argv);
|
||||
if (Err)
|
||||
return Err;
|
||||
|
||||
ViewOpts.Colors = !NoColors;
|
||||
|
||||
auto Coverage = load();
|
||||
if (!Coverage)
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user