aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-07-05 12:31:32 +0000
committerNico Weber <nicolasweber@gmx.de>2019-07-05 12:31:32 +0000
commit02536991a6000c5c0d1ec5f57ca25f2ef7b755e8 (patch)
tree7e97172dd79e288a687d499779d778dca267ddf0
parentdd555f13819bbdedfcdc3852a7d1591bd73df0f8 (diff)
lld, llvm-dlltool, llvm-lib: Use getAsString() instead of getSpelling() for printing unknown args
Since OPT_UNKNOWN args never have any values and consist only of spelling (and are never aliased), this doesn't make any difference in practice, but it's more consistent with Arg's guidance to use getAsString() for diagnostics, and it matches what clang does. Also tweak two tests to use an unknown option that contains '=' for additional coverage while here. (The new tests pass fine with the old code too though.) git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@365200 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--COFF/DriverUtils.cpp6
-rw-r--r--ELF/DriverUtils.cpp6
-rw-r--r--MinGW/Driver.cpp2
-rw-r--r--test/COFF/wx.s10
-rw-r--r--test/ELF/driver.test4
-rw-r--r--wasm/Driver.cpp2
6 files changed, 15 insertions, 15 deletions
diff --git a/COFF/DriverUtils.cpp b/COFF/DriverUtils.cpp
index 35724e08d..02357ffef 100644
--- a/COFF/DriverUtils.cpp
+++ b/COFF/DriverUtils.cpp
@@ -826,9 +826,9 @@ opt::InputArgList ArgParser::parse(ArrayRef<const char *> Argv) {
for (auto *Arg : Args.filtered(OPT_UNKNOWN)) {
std::string Nearest;
if (Table.findNearest(Arg->getAsString(Args), Nearest) > 1)
- warn("ignoring unknown argument '" + Arg->getSpelling() + "'");
+ warn("ignoring unknown argument '" + Arg->getAsString(Args) + "'");
else
- warn("ignoring unknown argument '" + Arg->getSpelling() +
+ warn("ignoring unknown argument '" + Arg->getAsString(Args) +
"', did you mean '" + Nearest + "'");
}
@@ -861,7 +861,7 @@ ArgParser::parseDirectives(StringRef S) {
if (MissingCount)
fatal(Twine(Args.getArgString(MissingIndex)) + ": missing argument");
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
- warn("ignoring unknown argument: " + Arg->getSpelling());
+ warn("ignoring unknown argument: " + Arg->getAsString(Args));
return {std::move(Args), std::move(Exports)};
}
diff --git a/ELF/DriverUtils.cpp b/ELF/DriverUtils.cpp
index e985a077f..32f364ec6 100644
--- a/ELF/DriverUtils.cpp
+++ b/ELF/DriverUtils.cpp
@@ -135,10 +135,10 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) {
for (auto *Arg : Args.filtered(OPT_UNKNOWN)) {
std::string Nearest;
if (findNearest(Arg->getAsString(Args), Nearest) > 1)
- error("unknown argument '" + Arg->getSpelling() + "'");
+ error("unknown argument '" + Arg->getAsString(Args) + "'");
else
- error("unknown argument '" + Arg->getSpelling() + "', did you mean '" +
- Nearest + "'");
+ error("unknown argument '" + Arg->getAsString(Args) +
+ "', did you mean '" + Nearest + "'");
}
return Args;
}
diff --git a/MinGW/Driver.cpp b/MinGW/Driver.cpp
index 979d3091f..62d898240 100644
--- a/MinGW/Driver.cpp
+++ b/MinGW/Driver.cpp
@@ -105,7 +105,7 @@ opt::InputArgList MinGWOptTable::parse(ArrayRef<const char *> Argv) {
if (MissingCount)
fatal(StringRef(Args.getArgString(MissingIndex)) + ": missing argument");
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
- fatal("unknown argument: " + Arg->getSpelling());
+ fatal("unknown argument: " + Arg->getAsString(Args));
return Args;
}
diff --git a/test/COFF/wx.s b/test/COFF/wx.s
index 2b9dbbc21..21c3ca35f 100644
--- a/test/COFF/wx.s
+++ b/test/COFF/wx.s
@@ -1,15 +1,15 @@
# REQUIRES: x86
# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
-# RUN: not lld-link /out:%t.exe /entry:main -notarealoption /WX %t.obj 2>&1 | \
+# RUN: not lld-link /out:%t.exe /entry:main -notarealopt=ion /WX %t.obj 2>&1 | \
# RUN: FileCheck -check-prefix=ERROR %s
-# RUN: not lld-link /out:%t.exe /entry:main -notarealoption /WX:NO /WX %t.obj 2>&1 | \
+# RUN: not lld-link /out:%t.exe /entry:main -notarealopt=ion /WX:NO /WX %t.obj 2>&1 | \
# RUN: FileCheck -check-prefix=ERROR %s
-# RUN: lld-link /out:%t.exe /entry:main -notarealoption /WX /WX:NO %t.obj 2>&1 | \
+# RUN: lld-link /out:%t.exe /entry:main -notarealopt=ion /WX /WX:NO %t.obj 2>&1 | \
# RUN: FileCheck -check-prefix=WARNING %s
-# ERROR: error: ignoring unknown argument '-notarealoption'
-# WARNING: warning: ignoring unknown argument '-notarealoption'
+# ERROR: error: ignoring unknown argument '-notarealopt=ion'
+# WARNING: warning: ignoring unknown argument '-notarealopt=ion'
.text
.global main
diff --git a/test/ELF/driver.test b/test/ELF/driver.test
index 29a06171c..77f9828a0 100644
--- a/test/ELF/driver.test
+++ b/test/ELF/driver.test
@@ -1,10 +1,10 @@
# REQUIRES: x86
-# RUN: not ld.lld --unknown1 --unknown2 -m foo /no/such/file -lnosuchlib \
+# RUN: not ld.lld --unknown1 --unkn=own2 -m foo /no/such/file -lnosuchlib \
# RUN: 2>&1 | FileCheck -check-prefix=UNKNOWN %s
# UNKNOWN: unknown argument '--unknown1'
-# UNKNOWN: unknown argument '--unknown2'
+# UNKNOWN: unknown argument '--unkn=own2'
# UNKNOWN: unknown emulation: foo
# UNKNOWN: cannot open /no/such/file
# UNKNOWN: unable to find library -lnosuchlib
diff --git a/wasm/Driver.cpp b/wasm/Driver.cpp
index 1a2861268..a3852d47b 100644
--- a/wasm/Driver.cpp
+++ b/wasm/Driver.cpp
@@ -170,7 +170,7 @@ opt::InputArgList WasmOptTable::parse(ArrayRef<const char *> Argv) {
handleColorDiagnostics(Args);
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
- error("unknown argument: " + Arg->getSpelling());
+ error("unknown argument: " + Arg->getAsString(Args));
return Args;
}