[clang] Add --start-no-unused-arguments/--end-no-unused-arguments to silence some...
authorMartin Storsjö <martin@martin.st>
Sat, 1 Jan 2022 13:54:29 +0000 (15:54 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 11 Jan 2022 07:22:00 +0000 (09:22 +0200)
commit50ec1306d060e46e0d53c9f5d8a052e1b0d10d3b
tree5cedff8a26c80e081cbda15de4ecfaa602b95306
parent04867c3c51e7cb1fa828939e6756933054f45484
[clang] Add --start-no-unused-arguments/--end-no-unused-arguments to silence some unused argument warnings

When passing a set of flags to configure defaults for a specific
target (similar to the cmake settings `CLANG_DEFAULT_RTLIB`,
`CLANG_DEFAULT_UNWINDLIB`, `CLANG_DEFAULT_CXX_STDLIB` and
`CLANG_DEFAULT_LINKER`, but without hardcoding them in the binary),
some of the flags may cause warnings (e.g. `-stdlib=` when compiling C
code). Allow requesting selectively ignoring unused arguments among
some of the arguments on the command line, without needing to resort
to `-Qunused-arguments` or `-Wno-unused-command-line-argument`.

Fix up the existing diagnostics.c testcase. It was added in
response to PR12181 to fix handling of
`-Werror=unused-command-line-argument`, but the command line option
in the test (`-fzyzzybalubah`) now triggers "error: unknown argument"
instead of the intended warning. Change it into a linker input
(`-lfoo`) which triggers the intended diagnostic. Extend the
existing test case to check more cases and make sure that it keeps
testing the intended case.

Add testing of the new option to this existing test.

Differential Revision: https://reviews.llvm.org/D116503
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/diagnostics.c