From 9deb1d406f5b47004f60d6ae3f5bd80299d6efc3 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 19 Mar 2015 04:45:16 +0000 Subject: [PATCH] llvm-cov: Rename -color={always|never} to -use-color[=0] This is an ugly hack to fix the configure --enable-shared build. It turns out that *every cl::opt in LLVM* shows up in *every tool* in that configuration, which is hopelessly broken. This skirts around the issue by not colliding with another option's name, for now. I've also simplified the option implementation - the other "color" option used cl::boolOrDefault and was much nicer than what I'd written before. llvm-svn: 232704 --- llvm/tools/llvm-cov/CodeCoverage.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 1582347..0331a02 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -228,10 +228,6 @@ std::unique_ptr CodeCoverageTool::load() { return Coverage; } -namespace { -enum Colors { Auto, Always, Never }; -} - int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) { // Print a stack trace if we signal out. sys::PrintStackTraceOnErrorSignal(); @@ -298,22 +294,18 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) { "greater than the given threshold"), cl::cat(FilteringCategory)); - cl::opt Color( - "color", cl::desc("Configure color output:"), cl::init(Colors::Auto), - 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)); + cl::opt UseColor( + "use-color", cl::desc("Emit colored output (default=autodetect)"), + cl::init(cl::BOU_UNSET)); 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()); + ViewOpts.Colors = UseColor == cl::BOU_UNSET + ? sys::Process::StandardOutHasColors() + : UseColor == cl::BOU_TRUE; // Create the function filters if (!NameFilters.empty() || !NameRegexFilters.empty()) { -- 2.7.4