Page MenuHomePhabricator

[CMAKE] Make clang-tidy fail the build rather than trying to auto-fix

Authored by Fabien on Sep 23 2020, 11:55.



The current behavior when the clang-tidy option is enabled is to attempt
to auto-fix the issues. This is not the best approach:

  • It does not work for all the rules;
  • It makes other warnings (not auto-fixable) difficult to spot.

This diff changes the behavior to cause clang-tidy to fail the build
when an issue is encountered, by promoting the warnings to errors. This
will prevent the user from missing a warning which is not auto-fixed.

Note: this option could be set in the .clang-tidy configuration file,
but it seems to have a bug and enable all the checks which is not the
expected behavior.

Test Plan
cmake -GNinja .. \
ninja all check

Add some braces issues, then:


Check that the build fail with a clang-tidy error.

Diff Detail

rABC Bitcoin ABC
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.