Skip to content

clang-tidy: Make it actually useful. #518

Description

@michalhosna

lint.sh runs nowhere in CI, and .clang-tidy sets Checks: *, which enables every vendor check shipped with clang-tidy.

Why main looks green

.clang-tidy carries AnalyzeTemporaryDtors, removed in clang-tidy 16. clang-tidy rejects the key, exits 0, and falls back to the default check set — so Checks: * has never actually applied. Measured on one TU: 1 warning under main's config, dozens once the key is dropped. lint.sh passing on main means nothing.

scripts/lint.sh on main is also run-clang-tidy -p build with no source filter, so much of what it walked was CPM/dependency code rather than ours.

What a real run finds

With the key dropped, over src/, test/, benchmark/ — roughly 18,000 unique warnings, dominated by checks written for other projects' coding standards:

group share note
llvmlibc-*, altera-*, fuchsia-*, zircon-*, … ~2/3 vendor checks for LLVM's libc, FPGA compilers, Fuchsia — none apply here
misc-include-cleaner, readability-identifier-length, readability-magic-numbers most of the rest style/opinion
bugprone-*, performance-*, clang-analyzer-*, concurrency-*, cert-* ~350 the part worth acting on

The config is the problem, not the code.

Proposal

  • Replace Checks: * with an explicit list, dropping the vendor families outright.
  • Triage the ~350 bugprone / performance / analyzer findings.
  • Only then add a lint job to ci-pr.yml next to the existing format.sh --check.

Note on gating: WarningsAsErrors: '' means warnings alone don't fail the run, but run-clang-tidy still returns non-zero if any TU emits a clang-diagnostic-error. A gating job wants WarningsAsErrors set to the curated list, so warnings actually fail it.

Counts are approximate, from a full clang-tidy 19.1.7 run on Debian

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions