HomePhabricator

[CMAKE] Enable clang-tidy

Description

[CMAKE] Enable clang-tidy

Summary:
This diff enables running clang-tidy at build time.

The checks are defined in the src/.clang-tidy file, and apply to every
subdirectories as well. For now, a single check is enabled to replace
boost::lexical_cast<std::string> with std::to_string (see
https://releases.llvm.org/8.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/boost-use-to-string.html).
This check should never trigger since D5136 removes
boost::lexical_cast, and our libraries are not using boost.

Depends on D5136.

Test Plan:
Pre-requisite: with no clang-tidy installed:

cmake -GNinja ..

Check that cmake returns an error because it fails to find clang-tidy.

cmake -GNinja .. -DENABLE_CLANG_TIDY=OFF
ninja

Should return no error.

Install clang-tidy version >= 8.

cmake -GNinja ..
ninja check-all bitcoin-bench

Add a boost::lexical_cast<std::string> case in any bitcoin-abc source
file, then run ninja again. Check that clang-tidy applied the fix and
replaced it with std::to_string.
Note: it seems that clang-tidy does not always replace, but sometimes
only outputs the warning.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5138

Details

Provenance
FabienAuthored on Jan 30 2020, 17:38
FabienPushed on Feb 4 2020, 09:31
Reviewer
Restricted Project
Differential Revision
D5138: [CMAKE] Enable clang-tidy
Parents
rSTAGING91e0607fd2ab: rearrange ATMP in preparation for SigChecks accounting in mempool
Branches
Unknown
Tags
Unknown
References
tag: phabricator/base/15990