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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232704 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Bogner 2015-03-19 04:45:16 +00:00
parent 2c275b1f80
commit 12f0d20753

View 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()) {