<div dir="ltr">Not really.<div><br></div><div>Before, this was horribly broken and definitely contradicted they style guide. Now, it is just an open question of whether you are allowed to but a short function onto a single line and AFAIU, there is a bit of disagreement on that. And (with ColumnLimit == 0) clang-format will just leave the authors choice. Thus, if you wrap the function on multiple lines, it will also put the braces on their own line. If you decide put it on a single line, it will leave that intact.</div>
<div><br></div><div>And if one day, WebKit developers decide that this is not the way to go, single-line functions can be prevented by a flag flip.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 29, 2014 at 7:44 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</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 class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Tue, Apr 29, 2014 at 7:05 AM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: djasper<br>
Date: Tue Apr 29 09:05:20 2014<br>
New Revision: 207527<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207527&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207527&view=rev</a><br>
Log:<br>
clang-format: Allow single-line function in WebKit style.<br>
<br>
Before:<br>
  void f() {<br>
      return; }<br>
<br>
After:<br>
  void f() { return; }<br>
<br>
Modified:<br>
    cfe/trunk/lib/Format/ContinuationIndenter.cpp<br>
    cfe/trunk/lib/Format/Format.cpp<br>
    cfe/trunk/unittests/Format/FormatTest.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=207527&r1=207526&r2=207527&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=207527&r1=207526&r2=207527&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)<br>
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Apr 29 09:05:20 2014<br>
@@ -207,8 +207,8 @@ bool ContinuationIndenter::mustBreak(con<br>
   // The following could be precomputed as they do not depend on the state.<br>
   // However, as they should take effect only if the UnwrappedLine does not fit<br>
   // into the ColumnLimit, they are checked here in the ContinuationIndenter.<br>
-  if (Previous.BlockKind == BK_Block && Previous.is(tok::l_brace) &&<br>
-      !Current.isOneOf(tok::r_brace, tok::comment))<br>
+  if (Style.ColumnLimit != 0 && Previous.BlockKind == BK_Block &&<br>
+      Previous.is(tok::l_brace) && !Current.isOneOf(tok::r_brace, tok::comment))<br>
     return true;<br>
<br>
   return false;<br>
<br>
Modified: cfe/trunk/lib/Format/Format.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=207527&r1=207526&r2=207527&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=207527&r1=207526&r2=207527&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/lib/Format/Format.cpp (original)<br>
+++ cfe/trunk/lib/Format/Format.cpp Tue Apr 29 09:05:20 2014<br>
@@ -499,6 +499,8 @@ public:<br>
       bool Newline =<br>
           Indenter->mustBreak(State) ||<br>
           (Indenter->canBreak(State) && State.NextToken->NewlinesBefore > 0);<br>
+      llvm::errs() << State.NextToken->Tok.getName() << " "<br>
+                   << Indenter->mustBreak(State) << "\n";<br>
       Indenter->addTokenToState(State, Newline, /*DryRun=*/false);<br>
     }<br>
   }<br>
<br>
Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=207527&r1=207526&r2=207527&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=207527&r1=207526&r2=207527&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Apr 29 09:05:20 2014<br>
@@ -8198,6 +8198,9 @@ TEST_F(FormatTest, FormatsWithWebKitStyl<br>
           "}",<br>
           Style));<br>
<br>
+  // Allow functions on a single line.<br>
+  verifyFormat("void f() { return; }", Style);<br></blockquote><div><br></div></div></div><div>This seems to contradict <a href="http://www.webkit.org/coding/coding-style.html#braces-function" target="_blank">http://www.webkit.org/coding/coding-style.html#braces-function</a> . What's the motivation for this change?</div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+<br>
   // Constructor initializers are formatted one per line with the "," on the<br>
   // new line.<br>
   verifyFormat("Constructor()\n"<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div><br></div></div>
</blockquote></div><br></div>