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

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 4 23:36:54 PDT 2024


================
@@ -2231,6 +2231,41 @@ struct FormatStyle {
   /// \version 3.7
   bool BreakBeforeTernaryOperators;
 
+  /// Different ways to break binary operations.
+  enum BreakBinaryOperationsStyle : int8_t {
+    /// Don't break binary operations
+    /// \code
+    ///    aaa + bbbb * ccccc - ddddd +
+    ///    eeeeeeeeeeeeeeee;
+    /// \endcode
+    BBO_Never,
+
+    /// Binary operations will either be all on the same line, or each operation
+    /// will have one line each.
+    /// \code
+    ///    aaa +
+    ///    bbbb *
+    ///    ccccc -
+    ///    ddddd +
+    ///    eeeeeeeeeeeeeeee;
+    /// \endcode
+    BBO_BreakAll,
+
+    /// Binary operations of a particular precedence that go beyond the column
+    /// limit will have one line each.
+    /// \code
+    ///    aaa +
+    ///    bbbb * ccccc -
+    ///    ddddd +
+    ///    eeeeeeeeeeeeeeee;
+    /// \endcode
+    BBO_BreakRespectPrecedence
----------------
owenca wrote:

```suggestion
    BBO_RespectPrecedence
```

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


More information about the cfe-commits mailing list