[PATCH] clang-format: Implement AlwaysBreakAfterDeclarationReturnType.
Daniel Jasper
djasper at google.com
Thu Jun 11 00:59:07 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;
+
----------------
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.
================
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)
----------------
I find the parentheses confusing.
================
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) ||
----------------
Call this IsDefinition.
http://reviews.llvm.org/D10370
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list