[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 2 06:48:11 PST 2018


djasper added a comment.

In https://reviews.llvm.org/D42787#1025117, @Typz wrote:

> If people don't care about this case, we might as well merge this :-) Just kidding.
>
> The tweak matches both our expectation, the auto-indent behaviour of IDE (not to be trusted, but still probably of 'default' behaviour for many people, esp. when you don't yet use a formatter), and its seems our code base is generally formatted like this. I think it is quite more frequent than 50 times in whole LLVM/Clang, but I have no actual numbers; do you have a magic tool to search for such specific "code pattern", or just run clang-format with one option then the next and count the differences ?


I just tweaked a search based on regular expressions. Fundamentally something like a line with an open paren and a comma that doesn't end in a comma gives a reasonable first approximation. But yes, first formatting with one option, then reformatting and looking at numbers of diffs would be interesting. And I would bet that even in your codebase diffs are few.

Also double-checked with Richard Smith and he agrees that the current behavior is preferable. For comma and plus this doesn't seem overly important, but making it:

  aaaaaaaaaa(bbbbbbbbb + ccccccccccc *
                         ddddddddd);

seems really bad to him as this suggests that we are adding both ccccccccccc and ddddddddd.

  aaaaaaaaaa(bbbbbbbbb + ccccccccccc *
                             ddddddddd);

seems clearer. And for consistency reasons, we should not treat those two cases differently.


Repository:
  rC Clang

https://reviews.llvm.org/D42787





More information about the cfe-commits mailing list