build: add clang-tidy integration#14660
Conversation
|
Needs proper attribution to lix contributors tho |
|
Yeah, I think we need to figure out how to do that (Co-Authored-By vs. notice in files vs. referencing the change-id from gerrit in the commit, etc) |
a0d63e1 to
5d11241
Compare
Co-authored-by is what we tended to do and referencing commit urls in messages. |
5d11241 to
1154932
Compare
|
Fixed with proper attribution :) |
1154932 to
c005ed1
Compare
|
@xokdvium i think this is good to go? |
|
Yeah this has been in my mind. Will review in the next few days. Very pumped to have this! |
nix-meson-build-support/common/clang-tidy/build_required_targets.py
Outdated
Show resolved
Hide resolved
xokdvium
left a comment
There was a problem hiding this comment.
Some minor comments and nitpicks. Otherwise seems great!
|
The CI needs some massaging. My CRTP mixin for CloneableError seems to anger clang-tidy :) |
c005ed1 to
0ad45a3
Compare
|
Ah nice, could we backport the second commit? |
The CRTP mixin had a publicly-accessible implicit default constructor, allowing misuse like 'class Foo : CloneableError<Bar, Error>' where Foo != Bar. clang-tidy's bugprone-crtp-constructor-accessibility flags this. Make construction private and befriend Derived. The explicit defaulted constructor is required: 'using Base::Base' does not count as user-declared for purposes of suppressing the implicit (public) default. The MakeError macro's 'using CloneableError<...>::CloneableError' re-export continues to work because the derived class is the friend.
In seekableGetNarBytes(path), the lambda init-captures 'inner = seekableGetNarBytes(fd.get())' and 'fd = ...std::move(fd)...' are unsequenced: C++ does not guarantee left-to-right evaluation of init-captures. If the move evaluates first, fd.get() reads from a moved-from AutoCloseFD. Hoist the inner call before the lambda to sequence it explicitly. Caught by clang-tidy's bugprone-use-after-move.
- Add meson infrastructure for clang-tidy in nix-meson-build-support/common/clang-tidy/ with compile_commands.json cleaning and parallel runner - Create custom clang-tidy plugin scaffolding in src/clang-tidy-plugin/ - Add enableClangTidyLayer in packaging/components.nix that runs clang-tidy on all C++ components via postBuild hook - Add clangTidy Hydra job in packaging/hydra.nix - Add clang-tidy CI job in .github/workflows/ci.yml to enforce on PRs - Document usage in doc/manual/source/development/static-analysis.md Uses debug build mode and skips tests for faster CI. Warnings are treated as errors to catch issues early. Inspired by Lix's clang-tidy implementation. Lix Change-Ids: - I1d2aa6ec32deb1db1fbd581127334db1b972323c - I3df5f5855712ab4f97d4e84d771e5e818f81f881 - Ifefe533f3b56874795de231667046b2da6ff2461 - Ifca22e443d357762125f4ad6bc4f568af3a26c62 Co-Authored-By: Jade Lovelace <lix@jade.fyi>
0ad45a3 to
9078eb9
Compare
Motivation
Just early days, partially a side-port of how Lix achieved this :)
Context
Fixes: #11839
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.