[PATCH] D42684: clang-format: Allow optimizer to break template declaration.

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 22 09:33:18 PDT 2018


djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Some last comments, but basically looks good.



================
Comment at: include/clang/Format/Format.h:352
 
-  /// \brief If ``true``, always break after the ``template<...>`` of a template
-  /// declaration.
-  /// \code
-  ///    true:                                  false:
-  ///    template <typename T>          vs.     template <typename T> class C {};
-  ///    class C {};
-  /// \endcode
-  bool AlwaysBreakTemplateDeclarations;
+  /// \brief Different ways to break after the template declaration.
+  enum BreakTemplateDeclarationsStyle {
----------------
Don't forget to run docs/tools/dump_format_style.py to update the docs.


================
Comment at: include/clang/Format/Format.h:355
+      /// Do not force break before declaration.
+      /// ``PenaltyBreakTemplateDeclaration`` is taken into account.
+      /// \code
----------------
I think it'd be worth having a case here that would actually be formatted differently with BTDS_MultiLine.


================
Comment at: lib/Format/TokenAnnotator.cpp:2248
+  if (Left.ClosesTemplateDeclaration)
+      return Style.PenaltyBreakTemplateDeclaration;
   if (Left.is(TT_ConditionalExpr))
----------------
Indentation is off


Repository:
  rC Clang

https://reviews.llvm.org/D42684





More information about the cfe-commits mailing list