Page MenuHomePhabricator

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

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

Details

Summary

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 .. \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++ \
  -DENABLE_CLANG_TIDY=ON
ninja all check

Add some braces issues, then:

ninja

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

Diff Detail

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