<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">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>This seems to contradict <a href="http://www.webkit.org/coding/coding-style.html#braces-function">http://www.webkit.org/coding/coding-style.html#braces-function</a> . What's the motivation for this change?</div>
<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">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><br></div></div>