Skip to content

Fix clang-tidy 23 findings and prepare .clang-tidy for it - #121371

Merged
thevar1able merged 18 commits into
masterfrom
clang-tidy-23-fixes
Oct 3, 2026
Merged

thevar1able merged 18 commits into
masterfrom
clang-tidy-23-fixes

Conversation

@thevar1able

@thevar1able thevar1able commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Related: #117346

Split out of the clang-23 toolchain PR so it can land on its own. clang-tidy 23 adds new checks and renames some existing ones, which fails the tidy build with about 188 unique findings across 22 check names. This PR:

  • disables the new noisy checks in .clang-tidy per the policy at the top of the file, including the new canonical names of already-disabled checks (bugprone-signed-bitwise for hicpp-signed-bitwise, portability-no-assembler for hicpp-no-assembler), the new aliases of google-explicit-constructor whose NOLINTs in the code reference the google name, and bugprone-unhandled-code-paths, which duplicates the enabled bugprone-switch-missing-default-case;
  • fixes the small mechanical findings: modernize-redundant-void-arg (std::function<void(void)> and similar in 7 places), readability-redundant-casting (22 redundant casts), readability-redundant-smartptr-get (.get()-> on smart pointers), and a NOLINT for bugprone-unsafe-to-allow-exceptions on the deliberately throwing ~SimpleFaultInjection.

The disabled check names that do not exist in clang-tidy 22 are ignored by it (clang-tidy --verify-config lists them as unknown, a normal run does not), so the config keeps working with the current toolchain. The compiler-diagnostic change (cmake/warnings.cmake) and the libc++ 23 build fix in gtest_compressionCodec.cpp from the original commits stay in the clang-23 PR.

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Prepare .clang-tidy and fix mechanical findings for clang-tidy 23.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/121371]

Version info

  • Merged into: 26.10.1.1404-master (included in 26.10 and later)

thevar1able and others added 3 commits September 21, 2026 16:16
clang-tidy 23 added new checks and renamed some existing ones, failing
the tidy build with ~188 unique findings across 22 check names.

Disable the new noisy checks in `.clang-tidy` (per the policy at the top
of the file), including the new canonical names of already-disabled
checks (`bugprone-signed-bitwise` for `hicpp-signed-bitwise`,
`portability-no-assembler` for `hicpp-no-assembler`) and the new
aliases of `google-explicit-constructor`, whose `NOLINT`s in the code
reference the google name.

Fix the small mechanical findings:
- `modernize-redundant-void-arg`: `std::function<void(void)>` and
  similar in 7 places.
- `readability-redundant-casting`: remove 11 redundant casts.
- `bugprone-unsafe-to-allow-exceptions`: `NOLINT` the deliberately
  throwing `~SimpleFaultInjection`.

Split out of the clang-23 toolchain PR; the compiler-diagnostic part of
the original commit (`cmake/warnings.cmake`) stays there.

CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=ed8367eb17b594dbb12b741e1354473f53f82c11&name_0=PR&name_1=Build%20%28arm_tidy%29
PR: #117346

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Disable `bugprone-unhandled-code-paths` (new in clang-tidy 23): all 7
findings were on switches already carrying
`NOLINT(bugprone-switch-missing-default-case)`, so the check duplicates
the enabled `bugprone-switch-missing-default-case` for this codebase.

Remove 11 redundant `static_cast<size_t>(i + 1)` casts flagged by
`readability-redundant-casting` in `gtest_coordination_changelog.cpp`;
`i` is already `size_t` in all of them.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=e687a44500e92d797a393e030550f128b219ffa9&name_0=PR&name_1=Build%20%28arm_tidy%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
clang-tidy 23 flags `.get()->` on smart pointers
(`readability-redundant-smartptr-get`) in more contexts.

Split out of the clang-23 toolchain PR; the libc++ 23 build fix in
`gtest_compressionCodec.cpp` from the original commit stays there.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116787&sha=da3ff9339cf7c2a77486aca83edd682a26824bb2&name_0=PR&name_1=Build%20%28arm_tidy%29
PR: #116787

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [caaa489]

Summary: ✅


AI Review

Summary

This PR updates .clang-tidy for the clang-tidy 23 rename/addition set and applies the corresponding mechanical cleanups across the tree: redundant void argument spellings, .get()-> dereferences on smart pointers, redundant casts, and assignment-in-condition rewrites. I did not find a remaining code-level correctness or safety issue in the current diff after checking the nontrivial control-flow refactors and the previously reported .clang-tidy alias problem.

Missing context / blind spots
  • ⚠️ The PR’s core contract is “clang-tidy 23 is clean / prepared”, but the latest Build (arm_tidy) check for caaa4899c31fb4bd8b2aa3a963fc88668e9abbed is still IN_PROGRESS. A passing tidy/build job on the final head would close the last end-to-end validation gap.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: let the final Build (arm_tidy) run on caaa4899c31fb4bd8b2aa3a963fc88668e9abbed finish successfully, or attach an equivalent clang-tidy 23 validation result for the final head.

LLVM Coverage Report

Measured on commit caaa489.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.80% +0.10%
Branches 79.50% 79.50% +0.00%

Changed lines: Changed C/C++ lines covered: 596/680 (87.65%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Sep 21, 2026
@Algunenano Algunenano self-assigned this Sep 21, 2026
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
Comment thread .clang-tidy Resolved
@rschu1ze

Copy link
Copy Markdown
Member

Ops, I noticed too late that @Algunenano assigned.

@Algunenano Algunenano assigned rschu1ze and unassigned Algunenano Sep 21, 2026
thevar1able and others added 6 commits September 21, 2026 18:28
…-static-initialization-cycle`

- Drop the "new in clang-tidy 23" remarks and give the reason for
  disabling instead.
- Say "alias of `google-explicit-constructor`" for the
  `cppcoreguidelines-` and `misc-` names.
- `bugprone-unhandled-code-paths` is not an alias of
  `bugprone-switch-missing-default-case` but a separate check that also
  flags `if`/`else if` chains without `else`; say so.
- Instead of disabling `misc-static-initialization-cycle`, add a
  `NOLINT` at the single place it fires (`QuotaKeyTypeInfo::get`).
- `readability-trivial-switch` flags single-case `switch` over enums,
  which we use deliberately for `-Wswitch` coverage;
  `bugprone-signed-bitwise` has about 2000 findings.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…-in-selection-statement`

Rewrite all assignments inside `if`/`while` conditions and inside
operands of `&&`/`||`. The type-dispatch chains of the form
`(res = execute<T1>(...)) || (res = execute<T2>(...)) || ...` in
`Functions/` now use `TypeListUtils::forEach` over a `TypeList`; the
other sites declare the variable in the condition, use an
init-statement, or assign before the check. Evaluation order and
short-circuiting are preserved, so there are no behavior changes.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Replace the hand-written rotate idiom `(x >> n) | (x << (w - n))` with
`std::rotr` in `intHash32` and in the Snappy CRC masking, and drop the
redundant `std::string` temporaries where the callee takes a
`std::string_view`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…-switch` succeed `hicpp-multiway-paths-covered`

The `hicpp` module was removed in clang-tidy 23 and
`hicpp-multiway-paths-covered`, which has been disabled here for years,
was split into these two checks.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 22, 2026
thevar1able and others added 2 commits September 24, 2026 15:21
# Conflicts:
#	src/Functions/FunctionsComparison.h
#	src/Parsers/ExpressionListParsers.cpp
This code is only compiled with `USE_BUZZHOUSE`, so it was missed by
the local clang-tidy run. Fixes `bugprone-assignment-in-if-condition`
reported by `arm_tidy`, and `bugprone-assignment-in-selection-statement`
which only clang-tidy 23 reports.

https://s3.amazonaws.com/clickhouse-test-reports/PRs/121371/fc9221b6d367a40760bfc07f273e93be4067ecdd/pr/build_arm_tidy/build_clickhouse/build_clickhouse.log
PR: #121371

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing caaa4899c with master 1b7e6cd8a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

110 object files changed (+1.22 MiB total), 0 added.

Object file Master PR Δ
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/greaterOrEquals.cpp.o 7.83 MiB 7.98 MiB +151.51 KiB (+1.89%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/lessOrEquals.cpp.o 7.82 MiB 7.97 MiB +151.14 KiB (+1.89%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/isDistinctFrom.cpp.o 7.70 MiB 7.84 MiB +150.21 KiB (+1.91%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/less.cpp.o 7.77 MiB 7.91 MiB +146.44 KiB (+1.84%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/greater.cpp.o 7.78 MiB 7.92 MiB +145.82 KiB (+1.83%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/isNotDistinctFrom.cpp.o 7.62 MiB 7.77 MiB +145.45 KiB (+1.86%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/equals.cpp.o 7.62 MiB 7.76 MiB +145.38 KiB (+1.86%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/notEquals.cpp.o 7.66 MiB 7.80 MiB +145.38 KiB (+1.85%)
src/Functions/array/CMakeFiles/clickhouse_functions_array.dir/range.cpp.o 594.37 KiB 669.05 KiB +74.68 KiB (+12.56%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

1502 translation units recompiled, 11055 s compile time in total, 1501 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +746.2 s (+7%) in total before that adjustment.

Job report

thevar1able and others added 2 commits September 25, 2026 11:30
The `readability-redundant-casting` cleanup dropped `static_cast<size_t>`
around `total_size - offset`. On Linux the subtraction is `unsigned long`,
the same as `size_t`, so the cast looked redundant. On Darwin `off_t` is
`long long`, so the result is `unsigned long long`, and `std::min` fails
to deduce a common type with `size_t`. Use `std::min<size_t>` instead,
which works on both platforms without a cast that clang-tidy flags.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121371&sha=c4fd591112d13f143f359f0d3dacddcc9511e3a8&name_0=PR&name_1=Build%20(arm_darwin)
#121371

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

⚠️ AI verdict: not_sure — no significant changes across 33 queries analysed

This PR is a clang-tidy cleanup: it moves assignments out of if/while conditions, removes redundant casts and .get() calls, and swaps manual rotates for std::rotr. None of these change how queries execute; the intHash32 rotate rewrite produces the same instructions. The five ClickBench GROUP BY flags (Q16, Q18, Q32, Q33, Q34: +6.7% to +16.2%) all stay not_sure. Q16 and Q33 fall inside master's current range, and two source runs shared a host, which fits a matching CPU slowdown across the board. The TPC-H Q1/Q7 speedups (-18.5%, -16.0%) are about 12 ms on fast queries with unstable baselines, so no performance change can be attributed to this PR.

clickbench

⚠️ 5 inconclusive

Flagged queries (5 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 16 not_sure 548 629 +14.9% <0.0001 aggregation: +14.9% stays inside master's current range, so the suppression holds. The PR's edits on this GROUP BY path, such as the intHash32 rotate rewrite, produce the same machine code.
⚠️ 18 not_sure 895 1040 +16.2% 0.0133 aggregation: +16.2% with mixed test results on a noisy GROUP BY query. Nothing in this lint cleanup changes how aggregation runs.
⚠️ 32 not_sure 741 825 +11.3% 0.0004 aggregation: +11.3% with mixed test results, and the measurements on both sides were very noisy. The diff only restructures conditions and does not touch the high-cardinality GROUP BY path.
⚠️ 33 not_sure 1153 1230 +6.7% 0.0002 aggregation: +6.7% stays inside master's current range, so the suppression holds. No changed code path in this PR can be tied to this query.
⚠️ 34 not_sure 1136 1220 +7.4% 0.0419 aggregation: +7.4% is borderline, with mixed test results. The GROUP BY URL path has no behavioral change in this diff.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 1 not_sure 65 53 -18.5% <0.0001 -18.5% (-12 ms) on a fast query whose master baseline is unstable. This lint-only diff cannot explain the change.
⚠️ 7 not_sure 81 68 -16.0% <0.0001 -16.0% (-13 ms) on a fast query whose master baseline is unstable. This lint-only diff cannot explain the change.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: afad5bf0-c81b-42c5-aae4-03d7c12603f0
  • MIRAI run: 3d39e31a-a217-4501-99a5-9dd27da65d42
  • PR check IDs:
    • clickbench_2944889_1790964930
    • clickbench_2944895_1790964930
    • clickbench_2944911_1790964929
    • tpch_adapted_1_official_2944931_1790964930
    • tpch_adapted_1_official_2944945_1790964930
    • tpch_adapted_1_official_2944960_1790964930

@clickhouse-gh clickhouse-gh Bot added comp-build-system Build system (CMake, compilation, platform builds). and removed comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Sep 28, 2026
# Conflicts:
#	src/Client/BuzzHouse/Generator/StatementGenerator.cpp
#	src/Coordination/KeeperStorage.cpp
Comment thread .clang-tidy Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Oct 1, 2026
@clickhouse-gh clickhouse-gh Bot removed the comp-build-system Build system (CMake, compilation, platform builds). label Oct 1, 2026
thevar1able and others added 3 commits October 2, 2026 14:01
The check was renamed to `bugprone-assignment-in-selection-statement` in
clang-tidy 23, but CI still runs an older clang-tidy that uses the old name
(it reported `src/Common/UTF8Helpers.cpp:144`). Disable both spellings and
the `cert-exp45-c` alias.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thevar1able
thevar1able added this pull request to the merge queue Oct 3, 2026
Merged via the queue into master with commit 4127c65 Oct 3, 2026
149 checks passed
@thevar1able
thevar1able deleted the clang-tidy-23-fixes branch October 3, 2026 11:43
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 3, 2026
alexey-milovidov added a commit to groeneai/ClickHouse that referenced this pull request Oct 4, 2026
`Build (amd_fuzzers)` on master fails again at the link step of
`clickhouse_fuzzer`, starting with 4127c65 (ClickHouse#121371):

    ld.lld-22: error: .../libclang_rt_asan.a(sanitizer_stackdepot.cpp.o):(function
    __sanitizer::(anonymous namespace)::CompressThread::NewWorkNotify(): .text+0x19e):
    relocation R_X86_64_PC32 out of range: 2148873898 is not in
    [-2147483648, 2147483647]; references section '.bss'

This is the same overflow as in e56a18c: the image sits right at the 2 GiB
reach of the small code model, and any commit can tip it over. Shaving a few
MiB again would only postpone the next failure, so remove the largest thing in
that range that the fuzzers do not need.

`-fsanitize=fuzzer-no-link` implies `-fsanitize-coverage=pc-table`, which
emits 16 bytes per instrumented edge into `__sancov_pcs`. It is a writable
section, so `lld` places it between `.text` and `.bss`. Measured on
`KeyCondition.cpp`, `InterpreterSelectQuery.cpp` and `FunctionsConversion.cpp`
compiled with the CI flags, it is 20-25% of the instrumented `.text`, i.e.
several hundred MiB for the whole image. With `-fno-sanitize-coverage=pc-table`
the `.text` and `__sancov_cntrs` are unchanged and `__sancov_pcs` is gone.

libFuzzer gets coverage feedback from the inline 8-bit counters; the PC table
only serves reporting (`cov:` in the progress lines, `NEW_FUNC`, `-print_pcs`,
`-print_coverage`, `-print_funcs`) and `-focus_function`, none of which CI uses.
`ft:` stays in the progress lines, and the report in `libfuzzer_test_check.py`
already treats `cov` as optional.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=501d978d7b9daa2036adbf79f930fae5db42219c&name_0=MasterCI&name_1=Build%20%28amd_fuzzers%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 4, 2026
…rement

Resolve the conflict in `src/Common/Increment.h` with master's clang-tidy 23
fixes (ClickHouse#121371): keep the `min_initial_value` / provider arguments of
`getBunch` and drop the redundant `static_cast<UInt64>` around the result,
as master did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-build-system Build system (CMake, compilation, platform builds). and removed comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-build-system Build system (CMake, compilation, platform builds). pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants