[PATCH] D91970: [lld/mac] Implement basic typo correction for flags
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 23 07:53:18 PST 2020
thakis created this revision.
thakis added a reviewer: int3.
thakis requested review of this revision.
Also use "unknown flag 'flag'" instead of "unknown flag: flag" for
consistency with the other ports.
https://reviews.llvm.org/D91970
Files:
lld/MachO/DriverUtils.cpp
lld/test/MachO/color-diagnostics.test
lld/test/MachO/driver.test
lld/test/MachO/silent-ignore.test
Index: lld/test/MachO/silent-ignore.test
===================================================================
--- lld/test/MachO/silent-ignore.test
+++ lld/test/MachO/silent-ignore.test
@@ -10,4 +10,4 @@
RUN: -ios_simulator_version_min 9.0.0 \
RUN: -sdk_version 13.2
RUN: not %lld -v --not-an-ignored-argument 2>&1 | FileCheck %s
-CHECK: error: unknown argument: --not-an-ignored-argument
+CHECK: error: unknown argument '--not-an-ignored-argument'
Index: lld/test/MachO/driver.test
===================================================================
--- /dev/null
+++ lld/test/MachO/driver.test
@@ -0,0 +1,4 @@
+# RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
+SPELLHELP: error: unknown argument '---help', did you mean '--help'
+# FIXME: This should say "no input files" instead
+SPELLHELP: error: undefined symbol: _main
Index: lld/test/MachO/color-diagnostics.test
===================================================================
--- lld/test/MachO/color-diagnostics.test
+++ lld/test/MachO/color-diagnostics.test
@@ -6,7 +6,7 @@
# RUN: not %lld -xyz --color-diagnostics=always /nosuchfile 2>&1 \
# RUN: | FileCheck -check-prefix=COLOR %s
-# COLOR: {{lld: .\[0;31merror: .\[0munknown argument: -xyz}}
+# COLOR: {{lld: .\[0;31merror: .\[0munknown argument '-xyz'}}
# COLOR: {{lld: .\[0;31merror: .\[0mcannot open /nosuchfile}}
# RUN: not %lld --color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
Index: lld/MachO/DriverUtils.cpp
===================================================================
--- lld/MachO/DriverUtils.cpp
+++ lld/MachO/DriverUtils.cpp
@@ -75,8 +75,14 @@
handleColorDiagnostics(args);
- for (opt::Arg *arg : args.filtered(OPT_UNKNOWN))
- error("unknown argument: " + arg->getSpelling());
+ for (auto *arg : args.filtered(OPT_UNKNOWN)) {
+ std::string nearest;
+ if (findNearest(arg->getAsString(args), nearest) > 1)
+ error("unknown argument '" + arg->getAsString(args) + "'");
+ else
+ error("unknown argument '" + arg->getAsString(args) +
+ "', did you mean '" + nearest + "'");
+ }
return args;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91970.307081.patch
Type: text/x-patch
Size: 2124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201123/83d8301d/attachment-0001.bin>
More information about the llvm-commits
mailing list