llvm-cov: Rename -color={always|never} to -use-color[=0]
authorJustin Bogner <mail@justinbogner.com>
Thu, 19 Mar 2015 04:45:16 +0000 (04:45 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 19 Mar 2015 04:45:16 +0000 (04:45 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232704 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-cov/CodeCoverage.cpp

index 1582347aacc269773cc964bfea8012f210f8a6cf..0331a02dfcc4cee9322f223f14fecdaf15e45d36 100644 (file)
@@ -228,10 +228,6 @@ std::unique_ptr<CoverageMapping> 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<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()) {