[PATCH] D116503: [clang] Add arguments for silencing unused argument warnings for some but not all arguments

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 2 14:52:03 PST 2022


mstorsjo created this revision.
mstorsjo added reviewers: aaron.ballman, sepavloff, phosek, MaskRay.
Herald added a subscriber: dang.
mstorsjo requested review of this revision.
Herald added a project: clang.

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 it 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116503

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/diagnostics.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116503.396956.patch
Type: text/x-patch
Size: 5190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220102/8058454b/attachment-0001.bin>


More information about the cfe-commits mailing list