This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Allow -warnings-as-errors to be specified from run_clang_tidy.py
Needs ReviewPublic

Authored by schaerfo on Oct 31 2020, 9:12 AM.

Details

Summary

This patch adds a -warnings-as-errors option to run_clang_tidy.py, which is forwarded to clang-tidy itself. This is done similar to the -header-filter option (as well as some others).

The rationale behind this is that previously, promoting warnings to errors when using run_clang_tidy was only possible through the .clang-tidy file and the -config option (which, however, overrides what is specified in .clang-tidy) and thus could not be changed without modifying this file. This comes in handy e. g. for CI, when you want the run to fail if certain warnings are emitted.

Diff Detail

Event Timeline

schaerfo created this revision.Oct 31 2020, 9:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 31 2020, 9:12 AM
schaerfo requested review of this revision.Oct 31 2020, 9:12 AM

Just a general drive by comment, there have been quite a few patches recently that add arguments that just get forwarded straight to clang-tidy, would it not be a whole lot simpler if we could just automatically forward arguments straight to clang-tidy.
clang-tidy itself uses the -- argument to signify any arguments after that get forwarded to the clang driver, this script could probably do the same.
The whole invocation could be like this:
py run_clang_tidy.py <tool_args> -- <clang_tidy_options> -- <options_forwarded_to_clang>
So a general use case could look like this:
py run_clang_tidy.py -p ./compile_commands.json -quiet -- -check=-*,bugprone* -warnings-as-errors=* -- -UNDEBUG

Anyway aside from that, please upload diffs with the full context, see https://llvm.org/docs/Phabricator.html#phabricator-request-review-web for more info.

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
242

s/py/by

schaerfo updated this revision to Diff 302152.Nov 1 2020, 9:00 AM

Just a general drive by comment, there have been quite a few patches recently that add arguments that just get forwarded straight to clang-tidy, would it not be a whole lot simpler if we could just automatically forward arguments straight to clang-tidy.

That is indeed an idea worth considering, perhaps I can start working on it. It would, however, not be backwards compatible.

Anyway aside from that, please upload diffs with the full context, see https://llvm.org/docs/Phabricator.html#phabricator-request-review-web for more info.

I have updated the revision to show the entire diff.