Skip to content

⬆️ Update clang-tidy to version 23 - #2328

Merged
burgholzer merged 40 commits into
mainfrom
codex/clang-tidy-23
Sep 5, 2026
Merged

⬆️ Update clang-tidy to version 23#2328
burgholzer merged 40 commits into
mainfrom
codex/clang-tidy-23

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

This PR updates MQT Core to clang-tidy 23 and adapts the C++ sources to the diagnostics exposed by the upgrade.

Codex assisted with the release-note audit, mechanical source updates, validation, and PR maintenance.

  • require clang-tidy 23 in the local cpp-lint session
  • pin all reusable MQT workflows to v2.3.1 at ae4c1005796fedc123c3c70cdba94ce643c9fcae
  • restore changed-file filtering after the full-tree Clang 23 canary
  • explicitly enable the four applicable new LLVM checks: llvm-formatv-string, llvm-redundant-casting, llvm-type-switch-case-types, and llvm-use-vector-utils
  • address the Clang 23 findings in focused commits, including diagnostics introduced by rebasing onto the updated main

LLVM 23 release-note audit

  • all configured check names and options remain valid in Clang 23
  • remove the now-redundant google-explicit-constructor config alias and update existing suppressions to the canonical misc-explicit-constructor name
  • the performance-faster-string-find rename requires no configuration edit because performance-* selects performance-prefer-single-char-overloads
  • account for five checks relocated from the removed hicpp module that are newly selected by existing wildcards
  • enable and address the applicable new LLVM checks, including llvm-type-switch-case-types
  • retain broadened defaults so the Clang 23 delta remains visible

Canary results

The first full-tree run used clang-tidy 23.1.1 from /usr/lib/llvm-23/bin and reported 673 clang-tidy findings and no clang-format findings. After the initial cleanup, the remaining 344 findings were resolved in grouped commits:

  • 244 misc-const-correctness
  • 55 modernize-use-structured-binding
  • 28 bugprone-signed-bitwise
  • 11 readability-trailing-comma
  • 5 readability-redundant-lambda-parameter-list
  • 1 readability-qualified-auto

All 42 temporary modernize-use-structured-binding suppressions were subsequently replaced with real structured-binding declarations for the initial returned state. Later state updates remain std::tie assignments because C++20 has no destructuring-assignment syntax. Rebasing onto the updated main exposed additional Clang 23 diagnostics in the new compiler, Qiskit, and OpenQASM code; these were addressed in separate follow-up commits.

Validation

  • uvx nox -s lint
  • uvx nox -s cpp-lint -- --all with clang-tidy 23.1.1: zero clang-format and clang-tidy findings
  • Clang 23 checks rerun for every affected diagnostic group and file, with no remaining actionable findings
  • clang-format 23 checked across every changed C/C++ file
  • all affected translation units and focused targets rebuilt successfully
  • focused OpenQASM regression coverage for invalid popcount, rotl, and rotr conditions
  • all 44 target-synthesis unit tests passed
  • mirrored mlir/.clang-tidy and bindings/mlir/.clang-tidy configurations verified identical
  • fresh CI for commit dc1465dcc is pending

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality. (Added focused regression coverage for invalid bit-vector builtin conditions.)
  • I have updated the documentation to reflect these changes. (Not needed; this only changes tooling and lint-driven implementation details.)
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed). (Not needed.)
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks. (Fresh CI is pending.)
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

@burgholzer

Copy link
Copy Markdown
Member

Side note here: It may be worth checking https://releases.llvm.org/23.1.0/tools/clang/tools/extra/docs/ReleaseNotes.html for checks that we should be explicitly enabling (e.g. a couple of the new LLVM checks)

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small comments on some new rules that should likely be enabled as well.
Edit: This should have only been a comment and not an approval; that then still needs all the fixes 🙃

Comment thread mlir/.clang-tidy Outdated
Comment thread mlir/.clang-tidy
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Important

Approval pending

CodeRabbit has no unresolved comments, but it has not reviewed the latest commit.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added conflict and removed conflict labels Sep 4, 2026
@mergify mergify Bot added conflict and removed conflict labels Sep 4, 2026
@mergify mergify Bot removed the conflict label Sep 4, 2026

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I genuinely like these changes quite a bit.
A good mixture of nicer formatting and more efficient LLVM API usage.

I just found three things (beyond the remaining linter errors) that I feel should be addressed here as well.
I'd actually argue that tonight (or tomorrow morning) would be a good time to get this PR merged as there is not too much other activity currently close to merge ready.
So I am already approving here just in case we manage to get this over the finish line quickly.

Comment thread mlir/include/mlir/Dialect/QCO/Utils/Matrix.h Outdated
Comment thread mlir/unittests/Dialect/QCO/Transforms/Optimizations/test_qco_pauli_twirling.cpp Outdated
Comment thread mlir/unittests/Dialect/QCO/Utils/test_dd_functionality.cpp Outdated
@mergify mergify Bot added the conflict label Sep 4, 2026
Temporarily run the complete C++ tree against the unreleased workflows change to surface new diagnostics.

Assisted-by: GPT-5.6 Sol via Codex
Assisted-by: GPT-5.6 Sol via Codex
Enable the new format string, redundant casting, and vector utility checks where they apply without opting into the complete LLVM check family.

Assisted-by: GPT-5.6 Sol via Codex
Include both fixable redundant template arguments and generic-lambda warnings in the Clang 23 canary so the final policy can be based on actual findings.

Assisted-by: GPT-5.6 Sol via Codex
Clang 23 registers misc-explicit-constructor through the existing misc wildcard, making the retained google alias redundant.

Assisted-by: GPT-5.6 Sol via Codex
Update clang-tidy suppressions from the retained Google alias to the Clang 23 misc check name.

Assisted-by: GPT-5.6 Sol via Codex
Enable all modernize checks except trailing return types and add the trailing-comma readability check in both mirrored MLIR profiles.

Assisted-by: GPT-5.6 Sol via Codex
Apply the Clang 23 readability fix to lambdas whose empty parameter lists are optional in C++20.

Assisted-by: GPT-5.6 Sol via Codex
Replace nested to_vector map and filter ranges with the dedicated LLVM helpers suggested by clang-tidy 23.

Assisted-by: GPT-5.6 Sol via Codex
Infer single Case types from explicit lambda parameters and replace generic lambda parameters with their MLIR handle types.

Assisted-by: GPT-5.6 Sol via Codex
Make shift widths and masks explicitly unsigned and handle the full signed exponent range without overflow.

Assisted-by: GPT-5.6 Sol via Codex
Use structured bindings for initialization and retain intentional tuple reassignments with narrow suppressions.

Assisted-by: GPT-5.6 Sol via Codex
Make both the deduced pointer and its pointee const as requested by readability-qualified-auto.

Assisted-by: GPT-5.6 Sol via Codex
Apply Clang 23 const-correctness suggestions to 205 immutable local values in the non-MLIR tests.

Assisted-by: GPT-5.6 Sol via Codex
Apply Clang 23 const-correctness suggestions to 14 immutable local values outside MLIR.

Assisted-by: GPT-5.6 Sol via Codex
Apply Clang 23 const-correctness suggestions to 11 local aliases that never mutate their referents.

Assisted-by: GPT-5.6 Sol via Codex
Use const pointees for read-only traversals and handles, retain mutable output buffers, and preserve the C ABI types of unused output parameters.

Assisted-by: GPT-5.6 Sol via Codex
Assisted-by: GPT-5.6 Sol via Codex
@simon1hofmann
simon1hofmann marked this pull request as ready for review September 4, 2026 22:06
@simon1hofmann

Copy link
Copy Markdown
Contributor Author

I genuinely like these changes quite a bit.
A good mixture of nicer formatting and more efficient LLVM API usage.

I just found three things (beyond the remaining linter errors) that I feel should be addressed here as well.
I'd actually argue that tonight (or tomorrow morning) would be a good time to get this PR merged as there is not too much other activity currently close to merge ready.
So I am already approving here just in case we manage to get this over the finish line quickly.

Note that the workflow is still pinned to the commit of this PR: munich-quantum-toolkit/workflows#448

Should we create a release in the workflows repo or just merge the PR there and pin main?

Replace the structured-binding suppressions with real declarations and adapt the QCO additions from the updated main branch.

Assisted-by: GPT-5.6 Sol via Codex
Carry the Clang 23 cleanup across the compiler and Qiskit changes added on main.

Assisted-by: GPT-5.6 Sol via Codex
Adapt the OpenQASM frontend and translation changes from main to the Clang 23 diagnostics.

Assisted-by: GPT-5.6 Sol via Codex
Place the matrix row comments on their initializer rows and use moduleOp consistently in the Pauli twirling tests.

Assisted-by: GPT-5.6 Sol via Codex
@mergify mergify Bot removed the conflict label Sep 4, 2026
Assisted-by: GPT-5.6 Sol via Codex
Assisted-by: GPT-5.6 Sol via Codex
@burgholzer

Copy link
Copy Markdown
Member

I genuinely like these changes quite a bit.
A good mixture of nicer formatting and more efficient LLVM API usage.

I just found three things (beyond the remaining linter errors) that I feel should be addressed here as well.
I'd actually argue that tonight (or tomorrow morning) would be a good time to get this PR merged as there is not too much other activity currently close to merge ready.
So I am already approving here just in case we manage to get this over the finish line quickly.

Note that the workflow is still pinned to the commit of this PR: munich-quantum-toolkit/workflows#448

Should we create a release in the workflows repo or just merge the PR there and pin main?

I'll quickly merge the workflows PR and draft a new patch release 👍🏻 thanks for pushing this to the finish line!

Use the stable release for all reusable workflows and restore
changed-file filtering after the full-tree Clang 23 canary.

Assisted-by: GPT-5.6 via Codex
Keep the standard range overloads when locating gate specifications and the
preferred entangler. Suppress the libstdc++-specific qualified-auto suggestion
because the standard does not require std::array iterators to be pointers.

Assisted-by: GPT-5.6 via Codex

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in 🚀

@burgholzer
burgholzer enabled auto-merge (squash) September 5, 2026 08:08
@burgholzer
burgholzer merged commit 7de5b25 into main Sep 5, 2026
32 of 35 checks passed
@burgholzer
burgholzer deleted the codex/clang-tidy-23 branch September 5, 2026 09:25
@denialhaag denialhaag added code quality Code quality improvements c++ Anything related to C++ code tooling Any issue or PR related to project tooling labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code code quality Code quality improvements tooling Any issue or PR related to project tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants