int main(int argc, const char *argv[]) {}
// RUN: llvm-profdata merge %S/Inputs/binary-formats.proftext -o %t.profdata
-// RUN: llvm-cov show %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata -no-colors -filename-equivalence %s | FileCheck %s
-// RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -no-colors -filename-equivalence %s | FileCheck %s
-// RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -no-colors -filename-equivalence %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/binary-formats.macho32l -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
int main(int argc, const char *argv[]) {}
// RUN: llvm-profdata merge %S/Inputs/universal-binary.proftext -o %t.profdata
-// RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -no-colors -filename-equivalence %s -arch x86_64 | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch x86_64 | FileCheck %s
-// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -no-colors -filename-equivalence %s -arch i386 2>&1 | FileCheck --check-prefix=WRONG-ARCH %s
+// RUN: not llvm-cov show %S/Inputs/universal-binary -instr-profile %t.profdata -filename-equivalence %s -arch i386 2>&1 | FileCheck --check-prefix=WRONG-ARCH %s
// WRONG-ARCH: Failed to load coverage
#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>
"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;
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;
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;