[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

Ameer J via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 09:52:23 PDT 2024


================
@@ -1203,6 +1214,10 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
     }
   }
 
+  if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) &&
+      (Previous.getPrecedence() > prec::Conditional)) {
+    CurrentState.BreakBeforeParameter = true;
----------------
ameerj wrote:

This is for cases such as this:
```c++
result = operand1 +
         operand2 -
         operand3 +
         operand4 -
         operand5 +
         operand6;
```
without it, the formatting could do this:
```c++
result = operand1 +
         operand2 -
         operand3 + operand4 - operand5 + operand6;
```

https://github.com/llvm/llvm-project/pull/95013


More information about the cfe-commits mailing list