[clang] [clang-format] Add ApplyAlwaysOnePerLineToTemplateArguments option (PR #137544)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 27 15:17:35 PDT 2025


================
@@ -1259,6 +1259,45 @@ struct FormatStyle {
   /// \version 3.7
   BinPackParametersStyle BinPackParameters;
 
+  /// If ``BinPackParameters`` is set to ``AlwaysOnePerLine``, specifies whether
+  /// template argument lists should also be split across multiple lines.
+  ///
+  /// When set to ``true``, each template argument will be placed on its own
+  /// line. When set to ``false``, template argument lists remain compact even
+  /// when function parameters are broken one per line.
+  ///
+  /// \code
+  ///   true:
+  ///   template <typename T, int N>
+  ///   struct Foo {
+  ///       T mData[N];
+  ///
+  ///       Foo<T,
+  ///           N>
+  ///       operator+(const Foo<T,
+  ///                           N> &other) const {}
+  ///
+  ///       Foo<T,
+  ///           N>
+  ///       bar(const Foo<T,
+  ///                     N> &other,
+  ///           float t) const {}
+  ///       };
+  ///
+  ///   false:
+  ///   template <typename T, int N>
+  ///   struct Foo {
+  ///       T mData[N];
+  ///
+  ///       Foo<T, N> operator+(const Foo<T, N> &other) const {}
+  ///
+  ///       Foo<T, N> bar(const Foo<T, N> &other,
+  ///                 float t) const {}
+  ///   };
+  /// \endcode
+  /// \version 21
+  bool ApplyAlwaysOnePerLineToTemplateArguments;
----------------
HazardyKnusperkeks wrote:

Please sort alphabetically.

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


More information about the cfe-commits mailing list