<div dir="ltr">Awesome, thanks! PR16185 comment 2 isn't quite perfect yet though as far as I can tell.<div><br></div><div>In a block, I get (I deleted some characters from the function names):</div><div><br></div><div>
<div>{</div><div> popup_wdow_.reset(</div><div> [[RenderWidgetPopupWindow alloc] iniithContentRect:NSMakRet(</div><div> origin_global.x, origin_global.y, pos.width(), pos.height())</div><div> syeMask:NSBorderlessWindowMask</div>
<div> bking:NSBackingStoreBuffered</div><div> der:NO]);</div><div>}</div></div><div><br></div><div>while this is probably worse than (manually-aligned)</div>
<div><br></div><div><div>{</div><div> popup_wdow_.reset(</div><div> [[RenderWidgetPopupWindow alloc]</div><div> iniithContentRect:NSMakRet(origin_global.x, origin_global.y,</div><div> pos.width(), pos.height())</div>
<div> syeMask:NSBorderlessWindowMask</div><div> bking:NSBackingStoreBuffered</div><div> der:NO]);</div><div>}</div></div><div><br></div><div>If I omit the outer block, I get</div>
<div><br></div><div><div>popup_window_.reset([[RenderWidgetPopupWindow alloc]</div><div> initWithContentRect:</div><div> NSMakeRect(origin_global.x, origin_global.y, pos.width(), pos.height())</div><div> styleMask:NSBorderlessWindowMask</div>
<div> backing:NSBackingStoreBuffered</div><div> defer:NO]);</div></div><div><br></div><div>but (manually-produced)</div><div><br></div><div><div>popup_window_.reset([[RenderWidgetPopupWindow alloc]</div>
<div> initWithContentRect:</div><div> NSMakeRect(origin_global.x, origin_global.y, pos.width(), pos.height())</div><div> styleMask:NSBorderlessWindowMask</div><div> backing:NSBackingStoreBuffered</div>
<div> defer:NO]);</div><div><br></div></div><div>is probably nicer.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 7, 2013 at 11:23 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: Thu Nov 7 13:23:49 2013<br>
New Revision: 194214<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=194214&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=194214&view=rev</a><br>
Log:<br>
clang-format: Improve ObjC variadic and binary expression parameters.<br>
<br>
Before:<br>
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |<br>
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |<br>
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];<br>
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa,<br>
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,<br>
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];<br>
<br>
After:<br>
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |<br>
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |<br>
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];<br>
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,<br>
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,<br>
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];<br>
<br>
This addresses <a href="http://llvm.org/PR15349" target="_blank">llvm.org/PR15349</a> and <a href="http://llvm.org/PR16185" target="_blank">llvm.org/PR16185</a>.<br>
<br>
Modified:<br>
cfe/trunk/lib/Format/ContinuationIndenter.cpp<br>
cfe/trunk/lib/Format/TokenAnnotator.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=194214&r1=194213&r2=194214&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=194214&r1=194213&r2=194214&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)<br>
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Nov 7 13:23:49 2013<br>
@@ -499,7 +499,8 @@ unsigned ContinuationIndenter::moveState<br>
// is special cased.<br>
bool SkipFirstExtraIndent =<br>
(Previous && (Previous->opensScope() || Previous->is(tok::kw_return) ||<br>
- Previous->getPrecedence() == prec::Assignment));<br>
+ Previous->getPrecedence() == prec::Assignment ||<br>
+ Previous->Type == TT_ObjCMethodExpr));<br>
for (SmallVectorImpl<prec::Level>::const_reverse_iterator<br>
I = Current.FakeLParens.rbegin(),<br>
E = Current.FakeLParens.rend();<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=194214&r1=194213&r2=194214&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=194214&r1=194213&r2=194214&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 7 13:23:49 2013<br>
@@ -871,8 +871,11 @@ public:<br>
<br>
/// \brief Parse expressions with the given operatore precedence.<br>
void parse(int Precedence = 0) {<br>
- // Skip 'return' as it is not part of a binary expression.<br>
- while (Current && Current->is(tok::kw_return))<br>
+ // Skip 'return' and ObjC selector colons as they are not part of a binary<br>
+ // expression.<br>
+ while (Current &&<br>
+ (Current->is(tok::kw_return) ||<br>
+ (Current->is(tok::colon) && Current->Type == TT_ObjCMethodExpr)))<br>
next();<br>
<br>
if (Current == NULL || Precedence > PrecedenceArrowAndPeriod)<br>
@@ -944,12 +947,11 @@ private:<br>
if (Current) {<br>
if (Current->Type == TT_ConditionalExpr)<br>
return prec::Conditional;<br>
- else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon)<br>
+ else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon ||<br>
+ Current->Type == TT_ObjCSelectorName)<br>
return 0;<br>
else if (Current->Type == TT_BinaryOperator || Current->is(tok::comma))<br>
return Current->getPrecedence();<br>
- else if (Current->Type == TT_ObjCSelectorName)<br>
- return prec::Assignment;<br>
else if (Current->isOneOf(tok::period, tok::arrow))<br>
return PrecedenceArrowAndPeriod;<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=194214&r1=194213&r2=194214&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=194214&r1=194213&r2=194214&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Nov 7 13:23:49 2013<br>
@@ -5373,10 +5373,18 @@ TEST_F(FormatTest, FormatObjCMethodExpr)<br>
" aaaaaaaaaa:bbbbbbbbbbbbbbbbb\n"<br>
" aaaaa:bbbbbbbbbbb + bbbbbbbbbbbb\n"<br>
" aaaa:bbb];");<br>
+ verifyFormat(<br>
+ "[self aaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |\n"<br>
+ " aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |\n"<br>
+ " aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];");<br>
<br>
// Variadic parameters.<br>
verifyFormat(<br>
"NSArray *myStrings = [NSArray stringarray:@\"a\", @\"b\", nil];");<br>
+ verifyFormat(<br>
+ "[self aaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n"<br>
+ " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n"<br>
+ " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];");<br>
}<br>
<br>
TEST_F(FormatTest, ObjCAt) {<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>