[lld] r290332 - Make -color-diagnostics an alias to -color-diagnostics=always.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 00:20:28 PST 2016


Author: ruiu
Date: Thu Dec 22 02:20:28 2016
New Revision: 290332

URL: http://llvm.org/viewvc/llvm-project?rev=290332&view=rev
Log:
Make -color-diagnostics an alias to -color-diagnostics=always.

Previously, that was an alias to -color-diagnostics=auto. However,
Clang's -fcolor-diagnostics is an alias to -fcolor-diagnostics=always,
so that was confusing. This patch fixes that issue.

Modified:
    lld/trunk/ELF/DriverUtils.cpp
    lld/trunk/ELF/Options.td
    lld/trunk/test/ELF/color-diagnostics.test

Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=290332&r1=290331&r2=290332&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Thu Dec 22 02:20:28 2016
@@ -56,9 +56,12 @@ ELFOptTable::ELFOptTable() : OptTable(Op
 static bool getColorDiagnostics(opt::InputArgList &Args) {
   bool Default = (ErrorOS == &errs() && Process::StandardErrHasColors());
 
-  auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_no_color_diagnostics);
+  auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq,
+                              OPT_no_color_diagnostics);
   if (!Arg)
     return Default;
+  if (Arg->getOption().getID() == OPT_color_diagnostics)
+    return true;
   if (Arg->getOption().getID() == OPT_no_color_diagnostics)
     return false;
 
@@ -68,7 +71,7 @@ static bool getColorDiagnostics(opt::Inp
   if (S == "always")
     return true;
   if (S != "never")
-    error("unknown -color-diagnostics value: " + S);
+    error("unknown option: -color-diagnostics=" + S);
   return false;
 }
 

Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=290332&r1=290331&r2=290332&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Thu Dec 22 02:20:28 2016
@@ -39,7 +39,10 @@ def allow_multiple_definition: F<"allow-
 def as_needed: F<"as-needed">,
   HelpText<"Only set DT_NEEDED for shared libraries if used">;
 
-def color_diagnostics: S<"color-diagnostics">,
+def color_diagnostics: F<"color-diagnostics">,
+  HelpText<"Use colors in diagnostics">;
+
+def color_diagnostics_eq: J<"color-diagnostics=">,
   HelpText<"Use colors in diagnostics">;
 
 def disable_new_dtags: F<"disable-new-dtags">,
@@ -252,7 +255,6 @@ def alias_Bstatic_dn: F<"dn">, Alias<Bst
 def alias_Bstatic_non_shared: F<"non_shared">, Alias<Bstatic>;
 def alias_Bstatic_static: F<"static">, Alias<Bstatic>;
 def alias_L__library_path: J<"library-path=">, Alias<L>;
-def alias_color_diagnostics: J<"color-diagnostics=">, Alias<color_diagnostics>;
 def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>;
 def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
 def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>;

Modified: lld/trunk/test/ELF/color-diagnostics.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/color-diagnostics.test?rev=290332&r1=290331&r2=290332&view=diff
==============================================================================
--- lld/trunk/test/ELF/color-diagnostics.test (original)
+++ lld/trunk/test/ELF/color-diagnostics.test Thu Dec 22 02:20:28 2016
@@ -1,13 +1,18 @@
 # Windows command prompt doesn't support ANSI escape sequences.
 # REQUIRES: shell
 
+# RUN: not ld.lld -xyz -color-diagnostics /nosuchfile 2>&1 \
+# RUN:   | FileCheck -check-prefix=COLOR %s
 # RUN: not ld.lld -xyz -color-diagnostics=always /nosuchfile 2>&1 \
 # RUN:   | FileCheck -check-prefix=COLOR %s
 
 # COLOR: {{ld.lld: .\[0;1;31merror: .\[0munknown argument: -xyz}}
 # COLOR: {{ld.lld: .\[0;1;31merror: .\[0mcannot open /nosuchfile}}
 
-# RUN: not ld.lld -color-diagnostics=always -no-color-diagnostics /nosuchfile 2>&1 \
+# RUN: not ld.lld /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
+# RUN: not ld.lld -color-diagnostics=never /nosuchfile 2>&1 \
 # RUN:   | FileCheck -check-prefix=NOCOLOR %s
+# RUN: not ld.lld -color-diagnostics=always -no-color-diagnostics \
+# RUN:   /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
 
 # NOCOLOR: ld.lld: error: cannot open /nosuchfile




More information about the llvm-commits mailing list