From 3e66509f6cf4c6eb48b931e719ef6e2426758247 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Wed, 24 Oct 2018 21:46:42 +0000 Subject: [SourceMgr][FileCheck] Obey -color by extending WithColor (Relands r344930, reverted in r344935, and now hopefully fixed for Windows.) While this change specifically targets FileCheck, it affects any tool using the same SourceMgr facilities. Previously, -color was documented in FileCheck's -help output, but -color had no effect. Now, -color obeys its documentation: it forces colors to be used in FileCheck diagnostics even when stderr is not a terminal. -color is especially helpful when combined with FileCheck's -v, which can produce a long series of diagnostics that you might wish to pipe to a pager, such as less -R. The WithColor extensions here will also help to clean up color usage in FileCheck's annotated dump of input, which is proposed in D52999. Reviewed By: JDevlieghere, zturner Differential Revision: https://reviews.llvm.org/D53419 llvm-svn: 345202 --- llvm/utils/FileCheck/FileCheck.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/utils/FileCheck/FileCheck.cpp') diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index 8ce1d9cbd09..bf3c3983cfa 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/FileCheck.h" using namespace llvm; @@ -108,6 +109,10 @@ static void DumpCommandLine(int argc, char **argv) { } int main(int argc, char **argv) { + // Enable use of ANSI color codes because FileCheck is using them to + // highlight text. + llvm::sys::Process::UseANSIEscapeCodes(true); + InitLLVM X(argc, argv); cl::ParseCommandLineOptions(argc, argv); -- cgit v1.2.3