[llvm] r232704 - llvm-cov: Rename -color={always|never} to -use-color[=0]

Justin Bogner mail at justinbogner.com
Wed Mar 18 21:45:17 PDT 2015


Author: bogner
Date: Wed Mar 18 23:45:16 2015
New Revision: 232704

URL: http://llvm.org/viewvc/llvm-project?rev=232704&view=rev
Log:
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.

Modified:
    llvm/trunk/tools/llvm-cov/CodeCoverage.cpp

Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=232704&r1=232703&r2=232704&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Wed Mar 18 23:45:16 2015
@@ -228,10 +228,6 @@ std::unique_ptr<CoverageMapping> CodeCov
   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, i
                "greater than the given threshold"),
       cl::cat(FilteringCategory));
 
-  cl::opt<Colors> 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<cl::boolOrDefault> 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()) {





More information about the llvm-commits mailing list