Skip to content

style: Raise our clang-format standard to clang-format 22 - #5421

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-clangformat
Open

style: Raise our clang-format standard to clang-format 22#5421
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-clangformat

Conversation

@lgritz

@lgritz lgritz commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Since we are very close to branching for 3.2, it's finally time to bump our clang-format standard from 17 to 22. We do this only every couple years or so (to avoid constant churn with every new clang release), and time it for right before a release, so we are simultaneously doing it in main and in what is imminently the next release family. (Diverging at any other time would make backports of other PRs through the year unnecessarily complicated with divergence.)

This PR is EXPECTED to fail the clang-format test, because we're bumping the clang-format version without fixing anything that subsequently needs reformatting in the code. This is ON PURPOSE. You can see from the failure logs the full accounting of what will change in the code. It's a lot (that's why we only do this every 4 or 5 LLVM versions / every few years), but in looking it over, I believe most changes are neutral or clear improvements, very few truly minor things that I preferred the old way. I did tweak some of the rules a bit to make things a little more pleasing to me, and for a couple headers that were previously excluded from clang-format, I bit the bullet and let it reformat those files (filesystem, imagebufalgo, string_view, thread).

After merging this, we will have a separate PR that makes the code conform to the new rules, after which we will pass the CI clang-format test again. This split allows the .clang-format rule changes to be backported or cherry-picked into other branches independently.

I expect that the way to proceed with PRs currently in flight is (a) cherry-pick this PR (.clang-format change) into the patch's branch, (b) run clang-format on just the changed code of the PR to make the patch's changed code conform to the new rules, (c) rebase the PR on main, and hopefully have no merge conflicts.

Since we are very close to branching for 3.2, it's finally time to
bump our clang-format standard from 17 to 22. We do this only every
couple years or so (to avoid constant churn with every new clang
release), and time it for right before a relase, so we are
simultaneously doing it in main and in what is imminently the next
release family. (Diverging at any other time then simultaneously with
branching would make backports of other PRs through the year
unnecessarily complicated with divergence.)

This PR is EXPECTED to fail the clang-format test, because we're
bumping the clang-format version without fixing anything that
subsequently needs reformatting in the code. This is ON PURPOSE.

First, we merge the clang-format version bump. Then we will have a
separate PR that makes the code conform to the new rules, after which
we will pass the CI clang-format test again.

This split into two commits serves two purposes:

1. It isolates the code reformatting into its own PR whose commit SHA
   can be added to .git-blame-ignore-revs, marking that change as not
   counting for git blame queries (in other words, to prevent me from
   being misattributed as the author of the lines whose formatting
   changes).

2. It lets the .clang-format rule change be backported or cherry-picked
   into the topic branches of the many PRs in flight, or even into release
   branches, without pulling all the other code changes with it.

I expect that the way to proceed with PRs currently in flight is (a)
cherry-pick this PR (.clang-format change) into the patch's branch,
(b) run clang-format on just the changed code of the PR to make the
patch's changed code conform to the clang-format 22 rules, (c) rebase
the PR on main, and hopefully have no merge conflicts.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz

lgritz commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

The clang-format CI failure is expected, and will be rectified by the follow-up reformatting PR.

The wheel failures are unrelated (obviously, they don't depend on .clang-format having been changed) and I am looking into that separately.

Don't let failing CI prevent review/approval of this.

@lgritz

lgritz commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

Objections or approvals? I'd like to get this in and minimize the interval in which PRs are uncertain about which side of the reformat boundary they will land on.

@lgritz

lgritz commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

I intend to merge this tomorrow if nobody specifically objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant