<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 12, 2015 at 2:59 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: Fri Jun 12 04:59:16 2015<br>
New Revision: 239600<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D239600-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=KfVKQqUftT1I92UEeM_f5QL3Nl2zLEWwXmwT6gm5r4I&s=Vp_XDw0xbyQI48DWzTZLVMWrkemquFHpR7Hw_FyJCB0&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=239600&view=rev</a><br>
Log:<br>
clang-format: Always add space before lambda-{<br>
<br>
Before:<br>
  int c = []() -> int *{ return 2; }();<br>
<br>
After:<br>
  int c = []() -> int * { return 2; }();<br></blockquote><div><br>Side note (& perhaps this is impossible to test in LLVM now, given how much clang-formatting has already happened): Do people usually put a space before the '*' when the type is mentioned in a non-declarative context (when they're not declaring a variable)<br><br>My usual habit, in things like template parameters, was not to bother with the space: std::vector<int*> - I've not really minded clang-format adding the space there and maybe that's other people's habit anyway, but here on the lambda return type it feels a bit more odd to me.<br><br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Based on patch by James Dennett (<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10410&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=KfVKQqUftT1I92UEeM_f5QL3Nl2zLEWwXmwT6gm5r4I&s=xVJ2JZDwZBFyVyrmrA0tZfbMo4ga0lZXRSWsp0fszSQ&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D10410</a>), thank you!<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="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Format_TokenAnnotator.cpp-3Frev-3D239600-26r1-3D239599-26r2-3D239600-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=KfVKQqUftT1I92UEeM_f5QL3Nl2zLEWwXmwT6gm5r4I&s=323UedmLnCv6u-N5bpTEfDfhraejbgQugGtJ0ZD_wFk&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=239600&r1=239599&r2=239600&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jun 12 04:59:16 2015<br>
@@ -1800,6 +1800,7 @@ bool TokenAnnotator::spaceRequiredBetwee<br>
     return true;<br>
   if (Left.is(TT_PointerOrReference))<br>
     return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||<br>
+           (Right.is(tok::l_brace) && Right.BlockKind == BK_Block) ||<br>
            (!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,<br>
                            tok::l_paren) &&<br>
             (Style.PointerAlignment != FormatStyle::PAS_Right &&<br>
<br>
Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_unittests_Format_FormatTest.cpp-3Frev-3D239600-26r1-3D239599-26r2-3D239600-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=KfVKQqUftT1I92UEeM_f5QL3Nl2zLEWwXmwT6gm5r4I&s=_6K9TMBnk62aGOaKZTzSvQVk5jVKMePG_G2a9HeoTfs&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=239600&r1=239599&r2=239600&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jun 12 04:59:16 2015<br>
@@ -10098,6 +10098,7 @@ TEST_F(FormatTest, FormatsLambdas) {<br>
<br>
   // Lambdas with return types.<br>
   verifyFormat("int c = []() -> int { return 2; }();\n");<br>
+  verifyFormat("int c = []() -> int * { return 2; }();\n");<br>
   verifyFormat("int c = []() -> vector<int> { return {2}; }();\n");<br>
   verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");<br>
   verifyGoogleFormat("auto a = [&b, c](D* d) -> D* {};");<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" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>