Add clang-tidy static analysis#15
Merged
Merged
Conversation
A bug-finding gate, not a restyle. A broad check set produced ~355 findings on a
single TU, almost all style or by-design (const-correctness, literal-suffix
casing, public members for NTTP, intentional numeric narrowing). The curated set
keeps bugprone-*/performance-*/portability-* and disables only the specific
checks that are false positives or fight bound's deliberate design, each with a
documented rationale in the config:
- misc-redundant-expression: fires on `<L> op <R>` template pairs it can't tell
apart pre-instantiation (and fold-expression identity seeds) — net FP
- bugprone-narrowing-conversions: intentional, guarded (MSVC C4244/C4305)
- bugprone-signed-char-misuse: i8 is a numeric raw-storage type
- bugprone-exception-escape: noexcept helpers route through the replaceable
raise() handler (traps under -fno-exceptions) by design
- branch-clone / enum-size / easily-swappable-parameters: FP / deliberate
The two genuine, intentional sites left are NOLINT'd in test code only (a
macro-expansion inc-dec FP in test_compound_assign, deliberate catch-alls in the
fuzz harness) — no suppressions in library headers. Full run over tests + examples
is clean (0 findings); confirmed the gate still fires on planted issues.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Dedicated job (clang-18) that configures with compile_commands and runs run-clang-tidy over the test + example TUs, scoping header diagnostics to include/bound/. WarningsAsErrors in .clang-tidy makes any finding fail the run; no build step needed since clang-tidy parses from the compile database. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds clang-tidy as a static-analysis CI gate — the layer above the sanitizers /
coverage / perf gates from the previous pass. It catches at parse/AST time what
runtime checks can't (bugprone integer/sign patterns, accidental copies, missing
moves, portability traps).
What's in it
.clang-tidy— a curated, correctness-only config. This is a bug-findinggate, not a restyle. A broad set produced ~355 findings on a single TU, almost
all style or by-design (const-correctness, literal-suffix casing, public members
for NTTP/memcpy, intentional numeric narrowing). The config keeps
bugprone-*/performance-*/portability-*and disables only the specificchecks that are false positives or fight bound's deliberate design — each with a
one-line rationale in the file:
misc-redundant-expression<L> op <R>template pairs it can't distinguish pre-instantiation (and fold-expr identity seeds) — net FPbugprone-narrowing-conversionsbugprone-signed-char-misusei8is a numeric raw-storage type; sign-extension is intendedbugprone-exception-escapenoexcepthelpers route errors through the replaceableraise()handler (traps under-fno-exceptions) by designbugprone-branch-clone/performance-enum-size/bugprone-easily-swappable-parametersintenums / pervasive numeric pairsThe only two genuine, intentional sites left are
// NOLINT'd in test codeonly (a macro-expansion inc-dec FP in
test_compound_assign, deliberatecatch-alls in the fuzz harness) — no suppressions in library headers.
CI job (
linux clang-tidy): configures with clang-18 + compile_commands andruns
run-clang-tidyover tests + examples, header-scoped toinclude/bound/.WarningsAsErrors: '*'fails the run on any finding.Verification
tests/*.cpp+examples/*.cpp: 0 findings.performance-for-range-copy) makes it fail.amalgamation is unaffected.
Follow-up
After this is green and merged, I'll add
linux clang-tidyto the requiredstatus checks on
main(currently 18 → 19).🤖 Generated with Claude Code