From 8781c425b379e0da70de6b5ae5bf9abcdc822daf Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 22 Dec 2016 08:20:28 +0000 Subject: [PATCH] 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. llvm-svn: 290332 --- lld/ELF/DriverUtils.cpp | 7 +++++-- lld/ELF/Options.td | 6 ++++-- lld/test/ELF/color-diagnostics.test | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index 086994cee98f..a81b133f674b 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 d7a699ae7c33..d436f056d013 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; def alias_Bstatic_non_shared: F<"non_shared">, Alias; def alias_Bstatic_static: F<"static">, Alias; def alias_L__library_path: J<"library-path=">, Alias; -def alias_color_diagnostics: J<"color-diagnostics=">, Alias; def alias_discard_all_x: Flag<["-"], "x">, Alias; def alias_discard_locals_X: Flag<["-"], "X">, Alias; def alias_dynamic_list: J<"dynamic-list=">, Alias; diff --git a/lld/test/ELF/color-diagnostics.test b/lld/test/ELF/color-diagnostics.test index ca165ea45478..074bba29c54a 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