summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/DriverUtils.cpp7
-rw-r--r--lld/ELF/Options.td6
-rw-r--r--lld/test/ELF/color-diagnostics.test7
3 files changed, 15 insertions, 5 deletions
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 086994cee98..a81b133f674 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -56,9 +56,12 @@ ELFOptTable::ELFOptTable() : OptTable(OptInfo) {}
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::InputArgList &Args) {
if (S == "always")
return true;
if (S != "never")
- error("unknown -color-diagnostics value: " + S);
+ error("unknown option: -color-diagnostics=" + S);
return false;
}
diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index d7a699ae7c3..d436f056d01 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -39,7 +39,10 @@ def allow_multiple_definition: F<"allow-multiple-definition">,
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<Bstatic>;
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>;
diff --git a/lld/test/ELF/color-diagnostics.test b/lld/test/ELF/color-diagnostics.test
index ca165ea4547..074bba29c54 100644
--- a/lld/test/ELF/color-diagnostics.test
+++ b/lld/test/ELF/color-diagnostics.test
@@ -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
OpenPOWER on IntegriCloud