[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 12 01:15:49 PST 2025


================
@@ -2252,6 +2252,25 @@ struct FormatStyle {
   /// \version 16
   BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon;
 
+  /// If ``true``, a line break will be placed before the ``>`` in a multiline
+  /// template declaration.
+  /// \code
+  ///    true:
+  ///    template <
+  ///        typename Foo,
+  ///        typename Bar,
+  ///        typename Baz
+  ///    >
+  ///
+  ///    false:
+  ///    template <
+  ///        typename Foo,
+  ///        typename Bar,
+  ///        typename Baz>
----------------
owenca wrote:

> Would `Always` look like:
> 
> ```
> template<typename T
> >
> ```

Yes, except that there is a space between `template` and `<` by `LLVM` default.

> So, should I change this from a true/false to an enum of Multiline/Never?

Yes. I haven't looked at your implementation yet, but are you doing `BreakBeforeTemplateCloser` or `TemplateCloserOnItsOwnLine`?

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


More information about the cfe-commits mailing list