<div dir="ltr">Yeah .. C++11 support is not complete ...</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 22, 2013 at 6:35 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">What about override and final? What about ')' followed by an identifier (say `void f() OVERRIDE`)?</div>
<div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 22, 2013 at 1:28 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: djasper<br>
Date: Wed May 22 03:28:26 2013<br>
New Revision: 182455<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182455&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182455&view=rev</a><br>
Log:<br>
Improve handling of trailing 'const'.<br>
<br>
Reduce the preference for breaking before a trailing 'const' according<br>
to review comments on r182362.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
    cfe/trunk/unittests/Format/FormatTest.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=182455&r1=182454&r2=182455&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=182455&r1=182454&r2=182455&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 22 03:28:26 2013<br>
@@ -959,6 +959,10 @@ unsigned TokenAnnotator::splitPenalty(co<br>
     return 150;<br>
   }<br>
<br>
+  // Breaking before a trailing 'const' is bad.<br>
+  if (Left.is(tok::r_paren) && Right.is(tok::kw_const))<br>
+    return 150;<br>
+<br>
   // In for-loops, prefer breaking at ',' and ';'.<br>
   if (<a href="http://Line.First.is" target="_blank">Line.First.is</a>(tok::kw_for) && Left.is(tok::equal))<br>
     return 4;<br>
@@ -1165,6 +1169,11 @@ bool TokenAnnotator::canBreakBefore(cons<br>
     // change the "binding" behavior of a comment.<br>
     return false;<br>
<br>
+  // We only break before r_brace if there was a corresponding break before<br>
+  // the l_brace, which is tracked by BreakBeforeClosingBrace.<br>
+  if (Right.isOneOf(tok::r_brace, tok::r_paren, tok::greater))<br>
+    return false;<br>
+<br>
   // Allow breaking after a trailing 'const', e.g. after a method declaration,<br>
   // unless it is follow by ';', '{' or '='.<br>
   if (Left.is(tok::kw_const) && Left.Parent != NULL &&<br>
@@ -1174,10 +1183,6 @@ bool TokenAnnotator::canBreakBefore(cons<br>
   if (Right.is(tok::kw___attribute))<br>
     return true;<br>
<br>
-  // We only break before r_brace if there was a corresponding break before<br>
-  // the l_brace, which is tracked by BreakBeforeClosingBrace.<br>
-  if (Right.isOneOf(tok::r_brace, tok::r_paren, tok::greater))<br>
-    return false;<br>
   if (Left.is(tok::identifier) && Right.is(tok::string_literal))<br>
     return true;<br>
   return (Left.isBinaryOperator() && Left.isNot(tok::lessless)) ||<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=182455&r1=182454&r2=182455&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182455&r1=182454&r2=182455&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 22 03:28:26 2013<br>
@@ -1929,9 +1929,23 @@ TEST_F(FormatTest, BreaksFunctionDeclara<br>
 }<br>
<br>
 TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {<br>
-  verifyFormat("void someLongFunction(int someLongParameter)\n"<br>
-               "    const;",<br>
-               getLLVMStyleWithColumns(45));<br>
+  verifyFormat("void someLongFunction(\n"<br>
+               "    int someLongParameter) const {}",<br>
+               getLLVMStyleWithColumns(46));<br>
+  FormatStyle Style = getGoogleStyle();<br>
+  Style.ColumnLimit = 47;<br>
+  verifyFormat("void\n"<br>
+               "someLongFunction(int someLongParameter) const {\n}",<br>
+               getLLVMStyleWithColumns(47));<br>
+  verifyFormat("void someLongFunction(\n"<br>
+               "    int someLongParameter) const {}",<br>
+               Style);<br>
+  verifyFormat("LoooooongReturnType\n"<br>
+               "someLoooooooongFunction() const {}",<br>
+               getLLVMStyleWithColumns(47));<br>
+  verifyFormat("LoooooongReturnType someLoooooooongFunction()\n"<br>
+               "    const {}",<br>
+               Style);<br>
<br>
   verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"<br>
                "    LOCKS_EXCLUDED(aaaaaaaaaaaaa);");<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><br></div>
</div></div></blockquote></div><br></div>