Closed davidebeatrici closed 1 month ago
Configuration:
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
# Setting AlignConsecutiveDeclarations to true would be nice but it doesn't work right with PointerAlignment=Right
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
# Global.h must always be included last
- Regex: 'Global.h'
Priority: 10000
# Since a lot of windows-headers rely on windows.h, it has to be included first
- Regex: 'windows.h'
Priority: 1
# Assign a priority < INT_MAX to all other includes in order to be able to force headers
# to come after them
- Regex: '.*'
Priority: 10
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 3
NamespaceIndentation: Inner
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: true
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: ForContinuationAndIndentation
Which version of clang-format gives you the "Before" code?
10
Bisected to 3e333cc82e42e1e2ecc974d896489eebe1a5edc2, which first appeared in 13.0.0.
Back in 2021... ouch. I'm surprised nobody else reported the bug in the meantime.
To be fair, I myself should've reported it earlier, but until now (bumping the tool version from 10 to 17 in a well established project) I had only encountered it a few times and in a somewhat regular fashion, leading me to think it could be a deliberate behavior change and the configuration needed to be fixed. Sorry about that.
In any case, thank you very much for fixing the bug so fast! Is there any chance for it to be backported?
I've added PR #106013 to the 19.X Release milestone.
Is there any chance for it to be backported?
The fix has been back ported to version 19.
Got it, thank you.
Before:
After:
Before:
After:
See my review in mumble-voip/mumble#6543.