[PATCH] clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

strager strager.nds at gmail.com
Thu Jun 11 14:15:40 PDT 2015


================
Comment at: include/clang/Format/Format.h:278-281
@@ -277,1 +277,6 @@
 
+  /// \brief If \c true, always break after function declaration return types.
+  ///
+  /// \see AlwaysBreakAfterDeclarationReturnType
+  bool AlwaysBreakAfterDeclarationReturnType;
+
----------------
djasper wrote:
> Hm.. I wonder whether we should really have two separate flags here or a single flag with an enum value, e.g. AlwaysBreakAfterReturnType with the values (No, DefinitionOnly, All).
> 
> Not sure we'll also need DeclarationOnly, but I don't think so.
That would break all `.clang-format` files with `AlwaysBreakAfterDefinitionReturnType` specified, yes?

================
Comment at: lib/Format/ContinuationIndenter.cpp:129-130
@@ -128,2 +128,4 @@
   if (Current.is(TT_FunctionDeclarationName) &&
-      !Style.AlwaysBreakAfterDefinitionReturnType && State.Column < 6)
+      !(Style.AlwaysBreakAfterDefinitionReturnType ||
+        Style.AlwaysBreakAfterDeclarationReturnType) &&
+      State.Column < 6)
----------------
djasper wrote:
> I find the parentheses confusing.
What's a better way to write this?

================
Comment at: lib/Format/TokenAnnotator.cpp:1546
@@ -1546,2 +1545,3 @@
       // and tok::lbrace.
-      Current->MustBreakBefore = true;
+      bool Definition = !Line.Last->isOneOf(tok::semi, tok::comment);
+      if ((Definition && Style.AlwaysBreakAfterDefinitionReturnType) ||
----------------
djasper wrote:
> Call this IsDefinition.
Will do.

http://reviews.llvm.org/D10370

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list