<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 13, 2015 at 6:53 PM, Yavuz Nuzumlalı <span dir="ltr"><<a href="mailto:manuyavuz@gmail.com" target="_blank">manuyavuz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><div style="white-space:pre-wrap"></div><div dir="auto" style="word-wrap:break-word">Thanks for the response Daniel,<div><br></div><div>Could you guide me on where can I look inside clang-format implementation to see how clang-format currently handles lambdas in other languages, so that I may try to implement the same functionality for Objective-C case?</div></div></div></div></blockquote><div><br></div><div>Not really, it is all in ContinuationIndenter.cpp. However, this is among the most complex code of clang-format and giving you details on how to do this probably would take me longer than looking at this myself. If you still want to try and take a look, feel free. I am happy to answer any specific questions you might have.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><div dir="auto" style="word-wrap:break-word"><div><br></div><div>Besides that, I have one more question, which is somewhat related to topic.</div><div><br></div><div>When I try to use clang-format to format the following simple code:<br><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">- (void)asdf {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">    </span>[UIView animateasdfasdf:0 animations:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">     </span>[UIView animations:^{ } done:YES];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">      </span>[UIView animations:^{ } completion:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">       </span>[UIView testasdfasdfsd:YES animations:^{ } completion:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">    </span>[UIView animations:^{ } tessd:YES completion:^{ }];</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div><br></div><div>Output is the following:<br><br><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal">- (void)asdf {</div><div style="margin:0px;line-height:normal">  [UIView animateasdfasdf:0</div><div style="margin:0px;line-height:normal">               animations:^{</div><div style="margin:0px;line-height:normal">               }];</div><div style="margin:0px;line-height:normal">  [UIView animations:^{</div><div style="margin:0px;line-height:normal">  }</div><div style="margin:0px;line-height:normal">                done:YES];</div><div style="margin:0px;line-height:normal">  [UIView animations:^{</div><div style="margin:0px;line-height:normal">  }</div><div style="margin:0px;line-height:normal">      completion:^{</div><div style="margin:0px;line-height:normal">      }];</div><div style="margin:0px;line-height:normal">  [UIView testasdfasdfsd:YES</div><div style="margin:0px;line-height:normal">      animations:^{</div><div style="margin:0px;line-height:normal">      }</div><div style="margin:0px;line-height:normal">      completion:^{</div><div style="margin:0px;line-height:normal">      }];</div><div style="margin:0px;line-height:normal">  [UIView animations:^{</div><div style="margin:0px;line-height:normal">  }</div><div style="margin:0px;line-height:normal">      tessd:YES</div><div style="margin:0px;line-height:normal">      completion:^{</div><div style="margin:0px;line-height:normal">      }];</div><div style="margin:0px;line-height:normal">}</div></div><span><div><span><br></span></div></span></div></div></div></div><div dir="auto" style="word-wrap:break-word"><div><div class="h5"><div><span>I think clang-format somehow decides to not use colon alignment but align using `</span>ContinuationIndentWidth` where there are more than one block parameters.</div><div><span>Is this an intended behavior? Seems like a bug to me.</span></div></div></div></div></blockquote><div><br></div><div>It is intentional. Column alignment with more than one internal block doesn't really work. And this is also explicitly written in Google's style guide: <a href="https://google.github.io/styleguide/objcguide.xml#Blocks">https://google.github.io/styleguide/objcguide.xml#Blocks</a></div><div><br></div><div>Independent of that some of you examples look like there are still other bugs in there.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto" style="word-wrap:break-word"><div><span>PS : I'm using the <span></span>default LLVM configuration for the above case.</span></div></div><span class="im"><div dir="auto" style="word-wrap:break-word"><div><span><blockquote type="cite">On 13 Dec 2015, at 16:42, Daniel Jasper <<a>djasper@google.com</a>> wrote:<br><br></blockquote></span></div></div></span><div class=""><div class="h5"><div dir="auto" style="word-wrap:break-word"><div><span><blockquote type="cite">Nope, this behavior isn't currently implemented. I agree that it might make sense, as it is similar to how clang-format treats lambdas at the end of several other parameters.<br><br>On Fri, Dec 11, 2015 at 4:08 PM, Yavuz Nuzumlalı <<a>cfe-dev@lists.llvm.org</a>> wrote:<br>Hi everyone,<br><br>I'm experiencing a problem with clang-format for my code.<br><br>I'm using ColumnLimit as 120. When I write some code like this:<br><br>[self testMethod:15 withBlock:^{<br><span style="white-space:pre-wrap">       </span>NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap"> </span>NSLog(@"asdfasdf");<br>}];<br><br>This code would be converted to this by clang-format:<br><br>[self testMethod:15<br>       withBlock:^{<br><span style="white-space:pre-wrap">   </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>       NSLog(@"asdfasdf");<br><span style="white-space:pre-wrap">      </span>   }];<br><br>That seems wrong to me because the method call before block variable actually fits in width of 120. I guess this is because clang-format behaves above code as a single method call and assumes it as one line. But I really want to not split the method like this because it feels weird.<br><br>Is there a way to accomplish this with current system?<br><br>I put my configuration file as an attachment.<br><br>Best<br><br><br>_______________________________________________<br>cfe-dev mailing list<br><a>cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br><br><br></blockquote></span></div></div>
</div></div></blockquote></div><br></div></div>