We should probably turn this off for LLVM style:<div><br></div><div>/^ *const;/ has only 1 match in include/llvm and 5 matches in include/clang.</div><div>/^ *[^(,]*) const;/ has 251 matches in include/llvm and 191 matches in include/clang.<br>
<br><div class="gmail_quote">On Tue, May 21, 2013 at 2:16 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: Tue May 21 04:16:31 2013<br>
New Revision: 182362<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182362&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182362&view=rev</a><br>
Log:<br>
Allow breaking before a trailing const.<br>
<br>
Before:<br>
void someLongFunction(<br>
int someLongParameter) const;<br>
<br>
After:<br>
void someLongFunction(int someLongParameter)<br>
const;<br>
<br>
Also slightly cleanup tests.<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=182362&r1=182361&r2=182362&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=182362&r1=182361&r2=182362&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue May 21 04:16:31 2013<br>
@@ -1187,7 +1187,7 @@ bool TokenAnnotator::canBreakBefore(cons<br>
tok::kw_class, tok::kw_struct) ||<br>
Right.isOneOf(tok::lessless, tok::arrow, tok::period, tok::colon) ||<br>
(Left.is(tok::r_paren) && Left.Type != TT_CastRParen &&<br>
- Right.isOneOf(tok::identifier, tok::kw___attribute)) ||<br>
+ Right.isOneOf(tok::identifier, tok::kw_const, tok::kw___attribute)) ||<br>
(Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||<br>
(Left.is(tok::l_square) && !Right.is(tok::r_square));<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=182362&r1=182361&r2=182362&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182362&r1=182361&r2=182362&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue May 21 04:16:31 2013<br>
@@ -1628,12 +1628,6 @@ TEST_F(FormatTest, PutEmptyBlocksIntoOne<br>
// Line break tests.<br>
//===----------------------------------------------------------------------===//<br>
<br>
-TEST_F(FormatTest, FormatsFunctionDefinition) {<br>
- verifyFormat("void f(int a, int b, int c, int d, int e, int f, int g,"<br>
- " int h, int j, int f,\n"<br>
- " int c, int ddddddddddddd) {}");<br>
-}<br>
-<br>
TEST_F(FormatTest, FormatsAwesomeMethodCall) {<br>
verifyFormat(<br>
"SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n"<br>
@@ -1914,6 +1908,30 @@ TEST_F(FormatTest, BreaksFunctionDeclara<br>
" bbbb bbbb);");<br>
}<br>
<br>
+TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {<br>
+ verifyFormat("void someLongFunction(int someLongParameter)\n"<br>
+ " const;",<br>
+ getLLVMStyleWithColumns(45));<br>
+<br>
+ verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"<br>
+ " LOCKS_EXCLUDED(aaaaaaaaaaaaa);");<br>
+ verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"<br>
+ " LOCKS_EXCLUDED(aaaaaaaaaaaaa);");<br>
+ verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"<br>
+ " LOCKS_EXCLUDED(aaaaaaaaaaaaa) {}");<br>
+<br>
+ verifyFormat(<br>
+ "void aaaaaaaaaaaaaaaaaa()\n"<br>
+ " __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n"<br>
+ " aaaaaaaaaaaaaaaaaaaaaaaaa));");<br>
+ verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"<br>
+ " __attribute__((unused));");<br>
+ verifyFormat(<br>
+ "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"<br>
+ " GUARDED_BY(aaaaaaaaaaaa);");<br>
+}<br>
+<br>
+<br>
TEST_F(FormatTest, BreaksDesireably) {<br>
verifyFormat("if (aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n"<br>
" aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n"<br>
@@ -2051,24 +2069,6 @@ TEST_F(FormatTest, FormatsBuilderPattern<br>
" ->aaaaaaaaaaaaaaaaa();");<br>
}<br>
<br>
-TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {<br>
- verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"<br>
- " LOCKS_EXCLUDED(aaaaaaaaaaaaa);");<br>
- verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"<br>
- " LOCKS_EXCLUDED(aaaaaaaaaaaaa);");<br>
- verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"<br>
- " LOCKS_EXCLUDED(aaaaaaaaaaaaa) {}");<br>
- verifyFormat(<br>
- "void aaaaaaaaaaaaaaaaaa()\n"<br>
- " __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n"<br>
- " aaaaaaaaaaaaaaaaaaaaaaaaa));");<br>
- verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"<br>
- " __attribute__((unused));");<br>
- verifyFormat(<br>
- "bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"<br>
- " GUARDED_BY(aaaaaaaaaaaa);");<br>
-}<br>
-<br>
TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {<br>
verifyFormat(<br>
"if (aaaaaaaaaaaaaaaaaaaaaaaaa ||\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>