Bump clang-format from 17.0.6 to 20.1.0 #2046
Merged
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.
Raises the ClangFormat version used to format our codebase from 17.0.6 to 20.1.0 for better compatibility with recent versions of clangd (which embeds its own clang-format). See ClangFormat 20.1 docs for reference.
The most significant change due to this upgrade is the formatting of list initializers, such as for compound literals, which does not seem to have a related configuration option (hence pre-ClangFormat 19 compatibility pains; it is not
SpaceAfterCStyleCast
orSpaceBeforeCpp11BracedList
):This upgrade also seems to insert a space after some
(paren)
which it may be (mis-)interpreting as as C-style cast. These changes are left as-is due to relatively minor impact (especially compared to the compound literal changes mentioned above).The last notable changes to mention are better handling of preprocessor macro definitions (e.g. applying existing rules, abbreviating to a single line, etc.). These changes are also left as-is due to relatively minor impact.
There is also this one particular change which confuses me, but I do not think it is worth going out of our way to address/prevent .
The ClangFormat configuration file is regenerated (via
--dump-config
) to explicitly address all new/changed/removed options. Notable changes (relative to the old ClangFormat 17 config or relative to ClangFormat 20 defaults) include:AlwaysBreakAfterReturnType: All
is renamed toBreakAfterReturnType: All
AlwaysBreakTemplateDeclarations: Multiline
renamed toBreakTemplateDeclarations: Multiline
BinPackParameters
is set toOnePerLine
(equivalent to former value offalse
).IndentExportBlock
is set tofalse
for consistency with otherIndent*
options (default istrue
).KeepEmptyLinesAtTheStartOfBlocks: false
renamed toKeepEmptyLines.AtStartOfBlock: false
.KeepEmptyLinesAtEOF: false
is renamed toKeepEmptyLines.AtEndOfFile: false
.KeepEmptyLines.AtStartOfFile
is set tofalse
for consistency with otherKeepEmptyLines
options (default istrue
).MainIncludeChar
is set toAny
(default isQuote
).All other options are left as their default values.