summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-05-10 18:19:02 +0000
committerNico Weber <nicolasweber@gmx.de>2018-05-10 18:19:02 +0000
commitcac2b3349ede9faf34c8f8fd2553a036c701c22b (patch)
treee4044e3df83edf0c41103233a8f62f71b0d663ab
parentd6beb320b4573a7841e5bfda4aa83219356312ff (diff)
downloadbcm5719-llvm-cac2b3349ede9faf34c8f8fd2553a036c701c22b.tar.gz
bcm5719-llvm-cac2b3349ede9faf34c8f8fd2553a036c701c22b.zip
lld-link: Add --color-diagnostics(={always,never,auto})?, --no-color-diagnostics flags.
This is most useful when using lld-link on a non-Win host (but it might become useful on Windows too if lld also grows a fansi-escape-codes flag). Also make the help for --color-diagnostic mention the valid values in ELF and wasm, and print the flag name with two dashes in diags, since the one-dash form is seen as a list of many one-letter flags in some contexts. https://reviews.llvm.org/D46693 llvm-svn: 332012
-rw-r--r--lld/COFF/DriverUtils.cpp25
-rw-r--r--lld/COFF/Options.td6
-rw-r--r--lld/ELF/DriverUtils.cpp8
-rw-r--r--lld/ELF/Options.td2
-rw-r--r--lld/wasm/Driver.cpp13
-rw-r--r--lld/wasm/Options.td2
6 files changed, 43 insertions, 13 deletions
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index 4890a9e0dfc..98751193f26 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -756,6 +756,28 @@ static const llvm::opt::OptTable::Info InfoTable[] = {
COFFOptTable::COFFOptTable() : OptTable(InfoTable, true) {}
+// Set color diagnostics according to --color-diagnostics={auto,always,never}
+// or --no-color-diagnostics flags.
+static void handleColorDiagnostics(opt::InputArgList &Args) {
+ auto *Arg = Args.getLastArg(OPT_color_diagnostics, OPT_color_diagnostics_eq,
+ OPT_no_color_diagnostics);
+ if (!Arg)
+ return;
+ if (Arg->getOption().getID() == OPT_color_diagnostics) {
+ errorHandler().ColorDiagnostics = true;
+ } else if (Arg->getOption().getID() == OPT_no_color_diagnostics) {
+ errorHandler().ColorDiagnostics = false;
+ } else {
+ StringRef S = Arg->getValue();
+ if (S == "always")
+ errorHandler().ColorDiagnostics = true;
+ else if (S == "never")
+ errorHandler().ColorDiagnostics = false;
+ else if (S != "auto")
+ error("unknown option: --color-diagnostics=" + S);
+ }
+}
+
static cl::TokenizerCallback getQuotingStyle(opt::InputArgList &Args) {
if (auto *Arg = Args.getLastArg(OPT_rsp_quoting)) {
StringRef S = Arg->getValue();
@@ -799,6 +821,9 @@ opt::InputArgList ArgParser::parse(ArrayRef<const char *> Argv) {
if (MissingCount)
fatal(Twine(Args.getArgString(MissingIndex)) + ": missing argument");
+
+ handleColorDiagnostics(Args);
+
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
warn("ignoring unknown argument: " + Arg->getSpelling());
return Args;
diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index cc06fd5c488..4afc5f51303 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -20,6 +20,10 @@ def align : P<"align", "Section alignment">;
def aligncomm : P<"aligncomm", "Set common symbol alignment">;
def alternatename : P<"alternatename", "Define weak alias">;
def base : P<"base", "Base address of the program">;
+def color_diagnostics: Flag<["--"], "color-diagnostics">,
+ HelpText<"Use colors in diagnostics">;
+def color_diagnostics_eq: Joined<["--"], "color-diagnostics=">,
+ HelpText<"Use colors in diagnostics; one of 'always', 'never', 'auto'">;
def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
def delayload : P<"delayload", "Delay loaded DLL name">;
def entry : P<"entry", "Name of entry point symbol">;
@@ -46,6 +50,8 @@ def opt : P<"opt", "Control optimizations">;
def order : P<"order", "Put functions in order">;
def out : P<"out", "Path to file to write output">;
def natvis : P<"natvis", "Path to natvis file to embed in the PDB">;
+def no_color_diagnostics: F<"no-color-diagnostics">,
+ HelpText<"Do not use colors in diagnostics">;
def pdb : P<"pdb", "PDB file path">;
def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
def section : P<"section", "Specify section attributes">;
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index c768f9262cb..d7e4d56fca9 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -59,18 +59,18 @@ static void handleColorDiagnostics(opt::InputArgList &Args) {
OPT_no_color_diagnostics);
if (!Arg)
return;
- else if (Arg->getOption().getID() == OPT_color_diagnostics)
+ if (Arg->getOption().getID() == OPT_color_diagnostics) {
errorHandler().ColorDiagnostics = true;
- else if (Arg->getOption().getID() == OPT_no_color_diagnostics)
+ } else if (Arg->getOption().getID() == OPT_no_color_diagnostics) {
errorHandler().ColorDiagnostics = false;
- else {
+ } else {
StringRef S = Arg->getValue();
if (S == "always")
errorHandler().ColorDiagnostics = true;
else if (S == "never")
errorHandler().ColorDiagnostics = false;
else if (S != "auto")
- error("unknown option: -color-diagnostics=" + S);
+ error("unknown option: --color-diagnostics=" + S);
}
}
diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 582f70b0e26..b71804e7bb0 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -76,7 +76,7 @@ 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; one of 'always', 'never', 'auto'">;
defm cref: B<"cref",
"Output cross reference table",
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index deaa95cbc31..125a75a6e49 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -111,19 +111,18 @@ static void handleColorDiagnostics(opt::InputArgList &Args) {
OPT_no_color_diagnostics);
if (!Arg)
return;
-
- if (Arg->getOption().getID() == OPT_color_diagnostics)
+ if (Arg->getOption().getID() == OPT_color_diagnostics) {
errorHandler().ColorDiagnostics = true;
- else if (Arg->getOption().getID() == OPT_no_color_diagnostics)
+ } else if (Arg->getOption().getID() == OPT_no_color_diagnostics) {
errorHandler().ColorDiagnostics = false;
- else {
+ } else {
StringRef S = Arg->getValue();
if (S == "always")
errorHandler().ColorDiagnostics = true;
- if (S == "never")
+ else if (S == "never")
errorHandler().ColorDiagnostics = false;
- if (S != "auto")
- error("unknown option: -color-diagnostics=" + S);
+ else if (S != "auto")
+ error("unknown option: --color-diagnostics=" + S);
}
}
diff --git a/lld/wasm/Options.td b/lld/wasm/Options.td
index 1a396480b8b..566b36a4293 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -21,7 +21,7 @@ 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; one of 'always', 'never', 'auto'">;
defm demangle: B<"demangle",
"Demangle symbol names",
OpenPOWER on IntegriCloud