forked from OSchip/llvm-project
Add typo correction for command-line flags to ELF and COFF lld drivers
For lld-link, unknown '/'-style flags are treated as filenames on POSIX systems, so only '-'-style flags get typo correction for now. This matches clang-cl. PR37006. Differential Revision: https://reviews.llvm.org/D61443 llvm-svn: 360145
This commit is contained in:
parent
b4f028f0f3
commit
54743d5767
|
@ -858,8 +858,14 @@ opt::InputArgList ArgParser::parse(ArrayRef<const char *> Argv) {
|
|||
|
||||
handleColorDiagnostics(Args);
|
||||
|
||||
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
|
||||
warn("ignoring unknown argument: " + Arg->getSpelling());
|
||||
for (auto *Arg : Args.filtered(OPT_UNKNOWN)) {
|
||||
std::string Nearest;
|
||||
if (Table.findNearest(Arg->getAsString(Args), Nearest) > 1)
|
||||
warn("ignoring unknown argument '" + Arg->getSpelling() + "'");
|
||||
else
|
||||
warn("ignoring unknown argument '" + Arg->getSpelling() +
|
||||
"', did you mean '" + Nearest + "'");
|
||||
}
|
||||
|
||||
if (Args.hasArg(OPT_lib))
|
||||
warn("ignoring /lib since it's not the first argument");
|
||||
|
|
|
@ -132,8 +132,14 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> Argv) {
|
|||
if (MissingCount)
|
||||
error(Twine(Args.getArgString(MissingIndex)) + ": missing argument");
|
||||
|
||||
for (auto *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->getSpelling() + "'");
|
||||
else
|
||||
error("unknown argument '" + Arg->getSpelling() + "', did you mean '" +
|
||||
Nearest + "'");
|
||||
}
|
||||
return Args;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# RUN: not lld-link -xyz --color-diagnostics=always /nosuchfile 2>&1 \
|
||||
# RUN: | FileCheck -check-prefix=COLOR %s
|
||||
|
||||
# COLOR: {{lld-link: .\[0;1;35mwarning: .\[0mignoring unknown argument: -xyz}}
|
||||
# COLOR: {{lld-link: .\[0;1;35mwarning: .\[0mignoring unknown argument '-xyz'}}
|
||||
# COLOR: {{lld-link: .\[0;1;31merror: .\[0mcould not open /nosuchfile}}
|
||||
|
||||
# RUN: not lld-link /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
|
||||
|
|
|
@ -19,3 +19,11 @@ LIBBAD: ignoring /lib since it's not the first argument
|
|||
# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
|
||||
# RUN: not lld-link /out:/ %t.obj 2>&1 | FileCheck -check-prefix=DIR %s
|
||||
DIR: cannot open output file
|
||||
|
||||
# RUN: not lld-link -version 2>&1 | FileCheck -check-prefix=SPELLVERSION %s
|
||||
SPELLVERSION: ignoring unknown argument '-version', did you mean '--version'
|
||||
SPELLVERSION: no input files
|
||||
|
||||
# RUN: not lld-link -nodefaultlibs 2>&1 | FileCheck -check-prefix=SPELLNODEFAULTLIB %s
|
||||
SPELLNODEFAULTLIB: ignoring unknown argument '-nodefaultlibs', did you mean '-nodefaultlib'
|
||||
SPELLNODEFAULTLIB: no input files
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
# RUN: lld-link /out:%t.exe /entry:main -notarealoption /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 '-notarealoption'
|
||||
# WARNING: warning: ignoring unknown argument '-notarealoption'
|
||||
|
||||
.text
|
||||
.global main
|
||||
|
|
|
@ -234,7 +234,7 @@ _start:
|
|||
# NO_O_VAL: -o: missing argument
|
||||
|
||||
# RUN: not ld.lld --foo 2>&1 | FileCheck --check-prefix=UNKNOWN %s
|
||||
# UNKNOWN: unknown argument: --foo
|
||||
# UNKNOWN: unknown argument '--foo'
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: not ld.lld %t %t -o %t2 2>&1 | FileCheck --check-prefix=DUP %s
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# RUN: not ld.lld -xyz -color-diagnostics=always /nosuchfile 2>&1 \
|
||||
# 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}}
|
||||
|
||||
# RUN: not ld.lld -color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# RUN: not ld.lld --unknown1 --unknown2 -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 '--unknown1'
|
||||
# UNKNOWN: unknown argument '--unknown2'
|
||||
# UNKNOWN: unknown emulation: foo
|
||||
# UNKNOWN: cannot open /no/such/file
|
||||
# UNKNOWN: unable to find library -lnosuchlib
|
||||
|
@ -22,6 +22,9 @@
|
|||
# RUN: not ld.lld -v xyz 2>&1 | FileCheck -check-prefix=VERSION %s
|
||||
# VERSION: LLD {{.*}} (compatible with GNU linkers)
|
||||
|
||||
# RUN: not ld.lld --versin 2>&1 | FileCheck -check-prefix=SPELLVERSION %s
|
||||
# SPELLVERSION: unknown argument '--versin', did you mean '--version'
|
||||
|
||||
## Attempt to link DSO with -r
|
||||
# RUN: ld.lld -shared %t -o %t.so
|
||||
# RUN: not ld.lld -r %t.so %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR %s
|
||||
|
|
Loading…
Reference in New Issue