<div dir="ltr">Please try again to use Phabricator (it seems to be up again and context helps).<div><br></div><div>Two things I am wondering initially:</div><div>1. Do we really need all four combinations of the two boolean flags (for function calls and for control statements)? The answer might be yes, but I'd just like to make sure.</div>
<div>2. How does this affect constructor initializers (": a(1)") and variable declarations ("int a(1);")?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 3, 2013 at 6:56 PM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Added SpaceAfterFunctionName, which is needed for GNU coding style.<br></div><div><br></div><div>Phab is taking a day off, so the patch is just here:</div>
<div><br></div><div><font face="courier new, monospace">Index: include/clang/Format/Format.h</font></div>
<div><font face="courier new, monospace">===================================================================</font></div><div><font face="courier new, monospace">--- include/clang/Format/Format.h<span style="white-space:pre-wrap"> </span>(revision 196295)</font></div>
<div><font face="courier new, monospace">+++ include/clang/Format/Format.h<span style="white-space:pre-wrap"> </span>(working copy)</font></div><div><font face="courier new, monospace">@@ -260,6 +260,9 @@</font></div>
<div><font face="courier new, monospace"> /// and '('.</font></div><div><font face="courier new, monospace"> bool SpaceAfterControlStatementKeyword;</font></div><div><font face="courier new, monospace"> </font></div>
<div><font face="courier new, monospace">+ /// \brief If \c true, spaces will be inserted between function name and '('.</font></div><div><font face="courier new, monospace">+ bool SpaceAfterFunctionName;</font></div>
<div><font face="courier new, monospace">+</font></div><div><font face="courier new, monospace"> /// \brief If \c false, spaces will be removed before assignment operators.</font></div><div><font face="courier new, monospace"> bool SpaceBeforeAssignmentOperators;</font></div>
<div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace">@@ -317,6 +320,7 @@</font></div><div><font face="courier new, monospace"> SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&</font></div>
<div><font face="courier new, monospace"> SpaceAfterControlStatementKeyword ==</font></div><div><font face="courier new, monospace"> R.SpaceAfterControlStatementKeyword &&</font></div><div>
<font face="courier new, monospace">+ SpaceAfterFunctionName == R.SpaceAfterFunctionName &&</font></div><div><font face="courier new, monospace"> SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&</font></div>
<div><font face="courier new, monospace"> ContinuationIndentWidth == R.ContinuationIndentWidth;</font></div><div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace">Index: lib/Format/Format.cpp</font></div>
<div><font face="courier new, monospace">===================================================================</font></div><div><font face="courier new, monospace">--- lib/Format/Format.cpp<span style="white-space:pre-wrap"> </span>(revision 196295)</font></div>
<div><font face="courier new, monospace">+++ lib/Format/Format.cpp<span style="white-space:pre-wrap"> </span>(working copy)</font></div><div><font face="courier new, monospace">@@ -181,6 +181,7 @@</font></div><div><font face="courier new, monospace"> Style.SpacesInCStyleCastParentheses);</font></div>
<div><font face="courier new, monospace"> IO.mapOptional("SpaceAfterControlStatementKeyword",</font></div><div><font face="courier new, monospace"> Style.SpaceAfterControlStatementKeyword);</font></div>
<div><font face="courier new, monospace">+ IO.mapOptional("SpaceAfterFunctionName", Style.SpaceAfterFunctionName);</font></div><div><font face="courier new, monospace"> IO.mapOptional("SpaceBeforeAssignmentOperators",</font></div>
<div><font face="courier new, monospace"> Style.SpaceBeforeAssignmentOperators);</font></div><div><font face="courier new, monospace"> IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);</font></div>
<div><font face="courier new, monospace">@@ -267,6 +268,7 @@</font></div><div><font face="courier new, monospace"> LLVMStyle.SpaceInEmptyParentheses = false;</font></div><div><font face="courier new, monospace"> LLVMStyle.SpacesInCStyleCastParentheses = false;</font></div>
<div><font face="courier new, monospace"> LLVMStyle.SpaceAfterControlStatementKeyword = true;</font></div><div><font face="courier new, monospace">+ LLVMStyle.SpaceAfterFunctionName = false;</font></div><div><font face="courier new, monospace"> LLVMStyle.SpaceBeforeAssignmentOperators = true;</font></div>
<div><font face="courier new, monospace"> LLVMStyle.ContinuationIndentWidth = 4;</font></div><div><font face="courier new, monospace"> LLVMStyle.SpacesInAngles = false;</font></div><div><font face="courier new, monospace">@@ -316,6 +318,7 @@</font></div>
<div><font face="courier new, monospace"> GoogleStyle.SpaceInEmptyParentheses = false;</font></div><div><font face="courier new, monospace"> GoogleStyle.SpacesInCStyleCastParentheses = false;</font></div><div><font face="courier new, monospace"> GoogleStyle.SpaceAfterControlStatementKeyword = true;</font></div>
<div><font face="courier new, monospace">+ GoogleStyle.SpaceAfterFunctionName = false;</font></div><div><font face="courier new, monospace"> GoogleStyle.SpaceBeforeAssignmentOperators = true;</font></div><div><font face="courier new, monospace"> GoogleStyle.ContinuationIndentWidth = 4;</font></div>
<div><font face="courier new, monospace"> GoogleStyle.SpacesInAngles = false;</font></div><div><font face="courier new, monospace">Index: lib/Format/TokenAnnotator.cpp</font></div><div><font face="courier new, monospace">===================================================================</font></div>
<div><font face="courier new, monospace">--- lib/Format/TokenAnnotator.cpp<span style="white-space:pre-wrap"> </span>(revision 196295)</font></div><div><font face="courier new, monospace">+++ lib/Format/TokenAnnotator.cpp<span style="white-space:pre-wrap"> </span>(working copy)</font></div>
<div><font face="courier new, monospace">@@ -1295,7 +1295,8 @@</font></div><div><font face="courier new, monospace"> tok::semi) ||</font></div><div><font face="courier new, monospace"> (Style.SpaceAfterControlStatementKeyword &&</font></div>
<div><font face="courier new, monospace"> Left.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,</font></div><div><font face="courier new, monospace">- tok::kw_catch));</font></div>
<div><font face="courier new, monospace">+ tok::kw_catch)) ||</font></div><div><font face="courier new, monospace">+ (Style.SpaceAfterFunctionName && Left.is(tok::identifier));</font></div>
<div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace"> if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)</font></div><div><font face="courier new, monospace"> return false;</font></div>
<div><font face="courier new, monospace">Index: unittests/Format/FormatTest.cpp</font></div><div><font face="courier new, monospace">===================================================================</font></div><div><font face="courier new, monospace">--- unittests/Format/FormatTest.cpp<span style="white-space:pre-wrap"> </span>(revision 196295)</font></div>
<div><font face="courier new, monospace">+++ unittests/Format/FormatTest.cpp<span style="white-space:pre-wrap"> </span>(working copy)</font></div><div><font face="courier new, monospace">@@ -6637,6 +6637,33 @@</font></div>
<div><font face="courier new, monospace"> "}", NoSpace);</font></div><div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace">+TEST_F(FormatTest, ConfigurableSpaceAfterFunctionName) {</font></div>
<div><font face="courier new, monospace">+ FormatStyle Space = getLLVMStyle();</font></div><div><font face="courier new, monospace">+ Space.SpaceAfterControlStatementKeyword = false;</font></div><div><font face="courier new, monospace">+ Space.SpaceAfterFunctionName = true;</font></div>
<div><font face="courier new, monospace">+</font></div><div><font face="courier new, monospace">+ verifyFormat("int f ();", Space);</font></div><div><font face="courier new, monospace">+ verifyFormat("void f (int a, T b) {\n"</font></div>
<div><font face="courier new, monospace">+ " while(true)\n"</font></div><div><font face="courier new, monospace">+ " continue;\n"</font></div><div><font face="courier new, monospace">+ "}",</font></div>
<div><font face="courier new, monospace">+ Space);</font></div><div><font face="courier new, monospace">+ verifyFormat("if(true)\n"</font></div><div><font face="courier new, monospace">+ " f ();\n"</font></div>
<div><font face="courier new, monospace">+ "else if(true)\n"</font></div><div><font face="courier new, monospace">+ " f ();",</font></div><div><font face="courier new, monospace">+ Space);</font></div>
<div><font face="courier new, monospace">+ verifyFormat("do {\n"</font></div><div><font face="courier new, monospace">+ " do_something ();\n"</font></div><div><font face="courier new, monospace">+ "} while(something ());",</font></div>
<div><font face="courier new, monospace">+ Space);</font></div><div><font face="courier new, monospace">+ verifyFormat("switch(x) {\n"</font></div><div><font face="courier new, monospace">+ "default:\n"</font></div>
<div><font face="courier new, monospace">+ " break;\n"</font></div><div><font face="courier new, monospace">+ "}",</font></div><div><font face="courier new, monospace">+ Space);</font></div>
<div><font face="courier new, monospace">+}</font></div><div><font face="courier new, monospace">+</font></div><div><font face="courier new, monospace"> TEST_F(FormatTest, ConfigurableSpacesInParentheses) {</font></div><div>
<font face="courier new, monospace"> FormatStyle Spaces = getLLVMStyle();</font></div><div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace">@@ -6945,6 +6972,7 @@</font></div><div>
<font face="courier new, monospace"> CHECK_PARSE_BOOL(SpaceInEmptyParentheses);</font></div><div><font face="courier new, monospace"> CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);</font></div><div><font face="courier new, monospace"> CHECK_PARSE_BOOL(SpaceAfterControlStatementKeyword);</font></div>
<div><font face="courier new, monospace">+ CHECK_PARSE_BOOL(SpaceAfterFunctionName);</font></div><div><font face="courier new, monospace"> CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);</font></div><div><font face="courier new, monospace"> </font></div>
<div><font face="courier new, monospace"> CHECK_PARSE("AccessModifierOffset: -1234", AccessModifierOffset, -1234);</font></div><div><br></div>
</div>
</blockquote></div><br></div>