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
This commit is contained in:
Rui Ueyama 2016-12-22 08:20:28 +00:00
parent 0d1d49507b
commit 8781c425b3
3 changed files with 15 additions and 5 deletions

View File

@ -56,9 +56,12 @@ ELFOptTable::ELFOptTable() : OptTable(OptInfo) {}
static bool getColorDiagnostics(opt::InputArgList &Args) { static bool getColorDiagnostics(opt::InputArgList &Args) {
bool Default = (ErrorOS == &errs() && Process::StandardErrHasColors()); 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) if (!Arg)
return Default; return Default;
if (Arg->getOption().getID() == OPT_color_diagnostics)
return true;
if (Arg->getOption().getID() == OPT_no_color_diagnostics) if (Arg->getOption().getID() == OPT_no_color_diagnostics)
return false; return false;
@ -68,7 +71,7 @@ static bool getColorDiagnostics(opt::InputArgList &Args) {
if (S == "always") if (S == "always")
return true; return true;
if (S != "never") if (S != "never")
error("unknown -color-diagnostics value: " + S); error("unknown option: -color-diagnostics=" + S);
return false; return false;
} }

View File

@ -39,7 +39,10 @@ def allow_multiple_definition: F<"allow-multiple-definition">,
def as_needed: F<"as-needed">, def as_needed: F<"as-needed">,
HelpText<"Only set DT_NEEDED for shared libraries if used">; 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">; HelpText<"Use colors in diagnostics">;
def disable_new_dtags: F<"disable-new-dtags">, 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_non_shared: F<"non_shared">, Alias<Bstatic>;
def alias_Bstatic_static: F<"static">, Alias<Bstatic>; def alias_Bstatic_static: F<"static">, Alias<Bstatic>;
def alias_L__library_path: J<"library-path=">, Alias<L>; 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_all_x: Flag<["-"], "x">, Alias<discard_all>;
def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>; def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>; def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>;

View File

@ -1,13 +1,18 @@
# Windows command prompt doesn't support ANSI escape sequences. # Windows command prompt doesn't support ANSI escape sequences.
# REQUIRES: shell # 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: not ld.lld -xyz -color-diagnostics=always /nosuchfile 2>&1 \
# RUN: | FileCheck -check-prefix=COLOR %s # RUN: | FileCheck -check-prefix=COLOR %s
# COLOR: {{ld.lld: .\[0;1;31merror: .\[0munknown argument: -xyz}} # COLOR: {{ld.lld: .\[0;1;31merror: .\[0munknown argument: -xyz}}
# COLOR: {{ld.lld: .\[0;1;31merror: .\[0mcannot open /nosuchfile}} # 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: | 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 # NOCOLOR: ld.lld: error: cannot open /nosuchfile