Integrate clang-tidy
(take 2)
#981
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #666 (follow up to premature attempt: #980)
In this PR:
.clang-tidy
file appropriate for interactive developer useclang-tidy
under CISidenote: I have not implemented a containerized approach because, unlike
clang-format
and./tools/run-clangcldocker.sh
,clang-tidy
needs to know how the build is configured and what command-line arguments are passed to the compiler. My understanding is thatclang-tidy
typically has access to this information in one of the following ways:-DCMAKE_CXX_CLANG_TIDY=...
, and letcmake
runclang-tidy
for each*.cpp
file, as part of the subsequent build-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
to generate./build/compile_commands.json
, and then pass this information via the-p
argument, like:jq --raw-output0 .[].file ./build/compile_commands.json | xargs -0 clang-tidy -p ./build/
With either approach, containerization seems to offer little advantage, as
clang-tidy
is tightly coupled to the rest of the build toolchain regardless (configure-time feature detection, compiler flags, etc).