<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/105482>105482</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-format (20): Incorrect behavior with BreakBinaryOperations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kihot122
</td>
</tr>
</table>
<pre>
I believe clang-format is incorrectly formatting dereference operator with BreakBinaryOperations: OnePerLine
In example code:
`return segment < *this or *this < segment;`
Clang-format should correctly infer '*' operator in this context is not a multiplication but rather a dereference of this pointer. Instead I get the following formatting:
`return segment < *this or * this < segment;`
Full config:
`# clang-format >= 20
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: All
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BreakBeforeBraces: Custom
BreakBinaryOperations: OnePerLine
ColumnLimit: 250
IndentRequiresClause: false
IndentWidth: 4
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
TabWidth: 4
Standard: Latest
PenaltyExcessCharacter: 100
PenaltyIndentedWhitespace: 10
PenaltyReturnTypeOnItsOwnLine: 1000
RequiresExpressionIndentation: OuterScope
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Always
`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVs1yqzgTfRp5o0oKBP7JggV27CrXl--Sur5TWcuiMboREiM1Sfz2Uwhsg-2ZyWwSF3261ef00Q93Th40QEKmSzJ9nvAGS2OTd1kaDBmb7E1-TLZ0D0rCB1ChuD48FMZWHKl0VGphrAWB6ki7ryj1geZgoQALWgA1NViOxtJPiSVdWuDvS6m5PWY-II12JEpppuEV7IvUQIJnEqTd362m8MWrWgEVJgcS9d_JLLCAjdXUwaECjZREK0pYiqV01Njzz_ZzDyHRksyCYfXVkI0rTaNyeuEjdQFtoTlhKWHzCxGpqa8tjEb48jpog5TTqlEoayWFp0X3DVLLsQRL-ViSoitQG6kR7CPdaofAc7qlB0CKJdDCKGU-Wy0vsv4n9vTf6W8apVoShRyVJiwaz5lEaxI9U9Ynp0KAc_83uSwk2KwoHGA7wYe4jyt50GmBYLMa9NJy8d4BlsqI963O22Z6pDKfqVKpPTRtiy7TP-ALvQmilBZcORggd6Wx6Iu4TKc7qQ8KTthUffKjuwavuIP1V23BOWn0TRLa5qZ-m_LC96Bu17jbz8pUtWl0_hP-bKSFlsa31lnrpvrmEptGC79PbuDrqsbjNfyFV_uc35NInaCtVn4n_oKqVhzhGYTig9146Xgp9SsX7-cRXXXZh1-55RUg2Ju45QLeLK_roYEp9f44az1e8hRV3Ln7EaPRGrVDjtBZe2yAHtZKfDf_JOjd4A9egau5uJpcF8z2v1cDre4W2KFtBN4N_aFvk7pWvxCs9t6-TlxCYSysOIryfmjdij2OdIHOCEuTH-8nvpVSXWfSXa0kel8NVRpMdAgZafU3mJ8gjM1vbNFeA74L7xA_51Xj0FRDwDfuiZVRTaVfZCW95GwanG6O9pzpd6VbKd646y47yJvM0SvbH1__A6h94-0abmhZXOs8Kza9aCO6Ke6QW8yK8wiH4XP0Tu4vvr_uYIdc57zT7IUjuP64fAXNFR7XX-35uyq55QLBtqgwCEa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