Files
llvm/lld/test/COFF/driver.test
Nico Weber 9b2830b46e lld-link, clang: Treat non-existent input files as possible spellos for option flags
OptTable treats arguments starting with / that aren't a known option
as filenames. This means lld-link's and clang-cl's typo correction for
unknown flags didn't do spell checking for misspelled options that start
with /.

I first tried changing OptTable, but that got pretty messy, see PR41787
comments 2 and 3.

Instead, let lld-link's and clang's (including clang-cl's) "file not
found" diagnostic check if a non-existent file looks like it could be a
mis-spelled option, and if so add a "did you mean" suggestion to the
"file not found" diagnostic.

While here, make formatting of a few diagnostics a bit more
self-consistent.

Fixes PR41787.

Differential Revision: https://reviews.llvm.org/D62276

llvm-svn: 361518
2019-05-23 17:58:33 +00:00

40 lines
1.8 KiB
Plaintext

# RUN: not lld-link nosuchfile.obj >& %t.log
# RUN: FileCheck -check-prefix=MISSING %s < %t.log
MISSING: 'nosuchfile.obj': {{[Nn]}}o such file or directory
# RUN: lld-link --version | FileCheck -check-prefix=VERSION %s
VERSION: {{LLD [0-9]+\.[0-9]+}}
# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
# RUN: lld-link /out:%t.dll /dll %t.obj
# RUN: not lld-link /out:%t.exe %t.dll 2>&1 | FileCheck -check-prefix=BADFILE %s
BADFILE: bad file type. Did you specify a DLL instead of an import library?
# RUN: lld-link /lib /help | FileCheck -check-prefix=LIBHELP %s
LIBHELP: OVERVIEW: LLVM Lib
# RUN: not lld-link /WX /lib 2>&1 | FileCheck -check-prefix=LIBBAD %s
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
# RUN: not lld-link /nodefaultlibs 2>&1 | FileCheck -check-prefix=SPELLNODEFAULTLIB_SLASH %s
SPELLNODEFAULTLIB_SLASH: could not open '/nodefaultlibs': {{.*}}; did you mean '/nodefaultlib'
SPELLNODEFAULTLIB_SLASH-NOT: no input files
# Getting flags as typo corrections for normal input files is a side effect
# of how spell checking for /-style flags is implemented.
# RUN: not lld-link force 2>&1 | FileCheck -check-prefix=SPELLFORCE %s
SPELLFORCE: could not open 'force': {{.*}}; did you mean '/force'
SPELLFORCE-NOT: no input files