]> granicus.if.org Git - clang/commitdiff
Move -fcolor-diagnostics logic to driver.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 4 Nov 2009 06:24:57 +0000 (06:24 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 4 Nov 2009 06:24:57 +0000 (06:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86014 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
tools/clang-cc/clang-cc.cpp

index 04463be37feecb16e08d52f796558939d483ef36..808c31c64828360a59a5ccccef6fe627d4d4e5a9 100644 (file)
@@ -955,9 +955,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
                    options::OPT_fno_diagnostics_show_option))
     CmdArgs.push_back("-fdiagnostics-show-option");
-  if (!Args.hasFlag(options::OPT_fcolor_diagnostics,
-                    options::OPT_fno_color_diagnostics))
-    CmdArgs.push_back("-fno-color-diagnostics");
+
+  // Color diagnostics are the default, unless the terminal doesn't support
+  // them.
+  if (Args.hasFlag(options::OPT_fcolor_diagnostics,
+                   options::OPT_fno_color_diagnostics) &&
+      llvm::sys::Process::StandardErrHasColors())
+    CmdArgs.push_back("-fcolor-diagnostics");
+
   if (!Args.hasFlag(options::OPT_fshow_source_location,
                     options::OPT_fno_show_source_location))
     CmdArgs.push_back("-fno-show-source-location");
index c09f44b7384c30ab2cc344c19ad81dae60db3b0e..671fc35d182b95642be8da4d0d40c1907bec2a82 100644 (file)
@@ -70,7 +70,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Host.h"
 #include "llvm/System/Path.h"
-#include "llvm/System/Process.h"
 #include "llvm/System/Program.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Target/TargetSelect.h"
@@ -284,10 +283,9 @@ MessageLength("fmessage-length",
               llvm::cl::value_desc("N"));
 
 static llvm::cl::opt<bool>
-NoColorDiagnostic("fno-color-diagnostics",
-                  llvm::cl::desc("Don't use colors when showing diagnostics "
-                             "(automatically turned off if output is not a "
-                             "terminal)."));
+PrintColorDiagnostic("fcolor-diagnostics",
+                     llvm::cl::desc("Use colors in diagnostics"));
+
 //===----------------------------------------------------------------------===//
 // C++ Visualization.
 //===----------------------------------------------------------------------===//
@@ -2160,8 +2158,7 @@ int main(int argc, char **argv) {
   DiagOpts.ShowFixits = !NoDiagnosticsFixIt;
   DiagOpts.ShowSourceRanges = PrintSourceRangeInfo;
   DiagOpts.ShowOptionNames = PrintDiagnosticOption;
-  DiagOpts.ShowColors = (!NoColorDiagnostic &&
-                         llvm::sys::Process::StandardErrHasColors());
+  DiagOpts.ShowColors = PrintColorDiagnostic;
   DiagOpts.MessageLength = MessageLength;
 
   // Create the diagnostic client for reporting errors or for