Page MenuHomePhabricator

[CMAKE] Enable clang-tidy
ClosedPublic

Authored by Fabien on Feb 3 2020, 12:34.

Details

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.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
clang-tidy
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 9239
Build 16423: Default Diff Build & Tests
Build 16422: arc lint + arc unit

Event Timeline

Fabien planned changes to this revision.Feb 3 2020, 13:00
This revision is now accepted and ready to land.Feb 3 2020, 16:33
This revision was automatically updated to reflect the committed changes.