<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hm. We do this deliberately in LLVM sometimes, though, when we're pushing up against the 80-column limit.</div><div><br></div><div><font face="Courier">int</font></div><div><font face="Courier">foo(int bar,</font></div><div><font face="Courier">    int baz);</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">int *</font></div><div><font face="Courier">foo2(int bar);</font></div><div><br></div><div>I grant you that this looks weird, but IMHO it's better than the alternative:</div><div><br></div><div><div><font face="Courier">int </font><span style="font-family: Courier; ">foo(</span></div><div><span style="font-family: Courier; ">  int bar,</span></div><div><font face="Courier">  int baz);</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">int *</font><span style="font-family: Courier; ">foo2(</span></div><div><span style="font-family: Courier; ">  int bar);</span></div></div><div><font face="Courier"><br></font></div><div>What happens in these cases?</div><div>Jordan</div><div><br></div><br><div><div><div>On Jan 2, 2013, at 0:44 , Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Author: djasper<br>Date: Wed Jan  2 02:44:14 2013<br>New Revision: 171357<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=171357&view=rev">http://llvm.org/viewvc/llvm-project?rev=171357&view=rev</a><br>Log:<br>Don't break after pointer or reference specifier.<br><br>This fixes <a href="http://llvm.org/PR14717">llvm.org/PR14717</a>.<br>Buggy format:<br>TypeSpecDecl *<br>    TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,<br>                         IdentifierInfo *II, Type *T) {<br><br>Now changed to:<br>TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,<br>                                   SourceLocation L, IdentifierInfo *II,<br>                                   Type *T) {<br><br>Modified:<br>    cfe/trunk/lib/Format/Format.cpp<br>    cfe/trunk/unittests/Format/FormatTest.cpp<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=171357&r1=171356&r2=171357&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=171357&r1=171356&r2=171357&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Format/Format.cpp (original)<br>+++ cfe/trunk/lib/Format/Format.cpp Wed Jan  2 02:44:14 2013<br>@@ -660,8 +660,7 @@<br>     for (int i = 1, e = Line.Tokens.size(); i != e; ++i) {<br>       TokenAnnotation &Annotation = Annotations[i];<br><br>-      Annotation.CanBreakBefore =<br>-          canBreakBetween(Line.Tokens[i - 1], Line.Tokens[i]);<br>+      Annotation.CanBreakBefore = canBreakBefore(i);<br><br>       if (Annotation.Type == TokenAnnotation::TT_CtorInitializerColon) {<br>         Annotation.MustBreakBefore = true;<br>@@ -896,7 +895,13 @@<br>     return true;<br>   }<br><br>-  bool canBreakBetween(const FormatToken &Left, const FormatToken &Right) {<br>+  bool canBreakBefore(unsigned i) {<br>+    if (Annotations[i - 1].Type == TokenAnnotation::TT_PointerOrReference ||<br>+        Annotations[i].Type == TokenAnnotation::TT_ConditionalExpr) {<br>+      return false;<br>+    }<br>+    const FormatToken &Left = Line.Tokens[i - 1];<br>+    const FormatToken &Right = Line.Tokens[i];<br>     if (<a href="http://Right.Tok.is">Right.Tok.is</a>(tok::r_paren) || <a href="http://Right.Tok.is">Right.Tok.is</a>(tok::l_brace) ||<br>         <a href="http://Right.Tok.is">Right.Tok.is</a>(tok::comment) || <a href="http://Right.Tok.is">Right.Tok.is</a>(tok::greater))<br>       return false;<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=171357&r1=171356&r2=171357&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=171357&r1=171356&r2=171357&view=diff</a><br>==============================================================================<br>--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan  2 02:44:14 2013<br>@@ -682,6 +682,16 @@<br>   verifyGoogleFormat("A<int**, int**> a;");<br> }<br><br>+TEST_F(FormatTest, DoesNotBreakBeforePointerOrReference) {<br>+  verifyFormat(<br>+      "int *someFunction(int LoooooooooooooooongParam1,\n"<br>+      "                  int LoooooooooooooooongParam2) {\n}");<br>+  verifyFormat(<br>+      "TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,\n"<br>+      "                                   SourceLocation L, IdentifierIn *II,\n"<br>+      "                                   Type *T) {\n}");<br>+}<br>+<br> TEST_F(FormatTest, LineStartsWithSpecialCharacter) {<br>   verifyFormat("(a)->b();");<br>   verifyFormat("--a;");<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br></blockquote></div><br></div></body></html>