llvm / llvm/llvm-project

Format change when upgrading clang-format from 19.1.7 to 20.1.7

Open
#164,951 1 comment 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

We recently trying to upgrade LLVM version including clang-format from from 19.1.7 to 20.1.7

There are no changes to the configuration, yet we have a lot of changes in the code due to line breaking.

An example would be from:

```
setSomeDummyParam(DummyParametersss{
.paramAaaa = true, .paramBbbbbbbbbbb = paramBbbbbbbbbbb, .paramCccccccccc = paramCccccccccc});
```
to:
```
setSomeDummyParam(
DummyParametersss{
.paramAaaa = true, .paramBbbbbbbbbbb = paramBbbbbbbbbbb, .paramCccccccccc = paramCccccccccc});
```
Names are anonymized to reflect their lengths.

In a big project such our, it creates a problem as we then end up with a change that modifies over 1600 files and creates almost 20k lines modified.

I tried to work with new parameters that were added/changed between releases, but none provided help to reduce the number of modified lines.

This is not the first time it happened to us. My expectation would be that until configuration is changes, no impact to the existing format should be done between releases, or at least we should have option to work with configuration to mitigate the impact.

Did I miss something that caused such behavior and it can be mitigated by configuration?

Maybe it would be good to consider such scenarios in the future to avoid such impacts even if major change is updated?

Here is my current configuration (from the top to bottom in the tree structure):

top level:
```
---
BreakBeforeBraces: Allman
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
UseTab: Never
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: false
AlignTrailingComments: false
AlignEscapedNewlinesLeft: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakStringLiterals: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DisableFormat: false
FixNamespaceComments: true
IncludeCategories:
- Regex: '^

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the sample formatting with clang-format 19.1.7 and 20.1.7 using the posted top-level and inner-directory configurations. Compare the resulting line breaks and investigate whether a configuration option mitigates the change; done means identifying the cause and documenting or implementing a workable compatibility path.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.