[lld/mac] Implement basic typo correction for flags
Also use "unknown flag 'flag'" instead of "unknown flag: flag" for consistency with the other ports. Differential Revision: https://reviews.llvm.org/D91970
This commit is contained in:
parent
b86a1cd2f8
commit
11b7625833
|
@ -852,7 +852,7 @@ opt::InputArgList ArgParser::parse(ArrayRef<const char *> argv) {
|
||||||
|
|
||||||
handleColorDiagnostics(args);
|
handleColorDiagnostics(args);
|
||||||
|
|
||||||
for (auto *arg : args.filtered(OPT_UNKNOWN)) {
|
for (opt::Arg *arg : args.filtered(OPT_UNKNOWN)) {
|
||||||
std::string nearest;
|
std::string nearest;
|
||||||
if (optTable.findNearest(arg->getAsString(args), nearest) > 1)
|
if (optTable.findNearest(arg->getAsString(args), nearest) > 1)
|
||||||
warn("ignoring unknown argument '" + arg->getAsString(args) + "'");
|
warn("ignoring unknown argument '" + arg->getAsString(args) + "'");
|
||||||
|
|
|
@ -133,7 +133,7 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> argv) {
|
||||||
if (missingCount)
|
if (missingCount)
|
||||||
error(Twine(args.getArgString(missingIndex)) + ": missing argument");
|
error(Twine(args.getArgString(missingIndex)) + ": missing argument");
|
||||||
|
|
||||||
for (auto *arg : args.filtered(OPT_UNKNOWN)) {
|
for (opt::Arg *arg : args.filtered(OPT_UNKNOWN)) {
|
||||||
std::string nearest;
|
std::string nearest;
|
||||||
if (findNearest(arg->getAsString(args), nearest) > 1)
|
if (findNearest(arg->getAsString(args), nearest) > 1)
|
||||||
error("unknown argument '" + arg->getAsString(args) + "'");
|
error("unknown argument '" + arg->getAsString(args) + "'");
|
||||||
|
|
|
@ -75,8 +75,14 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
|
||||||
|
|
||||||
handleColorDiagnostics(args);
|
handleColorDiagnostics(args);
|
||||||
|
|
||||||
for (opt::Arg *arg : args.filtered(OPT_UNKNOWN))
|
for (opt::Arg *arg : args.filtered(OPT_UNKNOWN)) {
|
||||||
error("unknown argument: " + arg->getSpelling());
|
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;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# RUN: not %lld -xyz --color-diagnostics=always /nosuchfile 2>&1 \
|
# RUN: not %lld -xyz --color-diagnostics=always /nosuchfile 2>&1 \
|
||||||
# RUN: | FileCheck -check-prefix=COLOR %s
|
# 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}}
|
# COLOR: {{lld: .\[0;31merror: .\[0mcannot open /nosuchfile}}
|
||||||
|
|
||||||
# RUN: not %lld --color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
|
# RUN: not %lld --color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# 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
|
|
@ -9,4 +9,4 @@ RUN: -objc_abi_version 2 \
|
||||||
RUN: -ios_simulator_version_min 9.0.0 \
|
RUN: -ios_simulator_version_min 9.0.0 \
|
||||||
RUN: -sdk_version 13.2
|
RUN: -sdk_version 13.2
|
||||||
RUN: not %lld -v --not-an-ignored-argument 2>&1 | FileCheck %s
|
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'
|
||||||
|
|
Loading…
Reference in New Issue