style: Raise our clang-format standard to clang-format 22 - #5421
Open
lgritz wants to merge 1 commit into
Open
Conversation
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>
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. |
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. |
Collaborator
Author
|
I intend to merge this tomorrow if nobody specifically objects. |
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.
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.