[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 5 10:16:39 PDT 2018


krasimir added a comment.

In https://reviews.llvm.org/D52676#1251391, @oleg.smolsky wrote:

> In https://reviews.llvm.org/D52676#1251342, @krasimir wrote:
>
> > Digging a bit further, seems like the behavior you're looking for could be achieved by setting the `AlignAfterOpenBracket` option to `DontAlign` or `AlwaysBreak`:
> >
> >   % clang-format -style='{BasedOnStyle: google, AlignAfterOpenBracket: AlwaysBreak}' test.cc
> >    void f() {
> >      something->Method2s(
> >          1,
> >          [this] {
> >            Do1();
> >            Do2();
> >          },
> >          1);
> >    }
> >    % clang-format -style='{BasedOnStyle: google, AlignAfterOpenBracket: DontAlign}' test.cc
> >    void f() {
> >      something->Method2s(1,
> >          [this] {
> >            Do1();
> >            Do2();
> >          },
> >          1);
> >    }
> >
> > Does this work for you?
>
>
> This is interesting. It obviously does what I want with the lambda, but forces this:
>
>   void f() {
>     auto stub = PopulateContextHereAndHereSomethi(GetSomethingHere(),
>                                                   GetSomethingElseHere());
>   }
>
>
> into this:
>
>   void f() {
>     auto stub = PopulateContextHereAndHereSomethi(
>         GetSomethingHere(), GetSomethingElseHere());
>   }
>
> The former looks better to me and that's what Emacs does when you press Tab. I think people here at work will balk at this formatting...
>
> > I don't think modifying the behavior as posed in this change based on the existence of multiline lambdas and the value of the `BinPackArguments` option is better than what we have now, especially when `AlignAfterOpenBracket=Align`.
>
> Yeah, I hear you. The patch is intended to work with `AlignAfterOpenBracket=Align` and `BinPackArguments=false` and only tweaks the lambdas' placement.
>
> How about I key the new behavior off a new value of `AlignAfterOpenBracket`, such as `AlignAfterOpenBracket=AlignExceptLambda`?


Sorry, I don't think we want to support something this specific. I'd like to hear djasper@ and klimek@ opinions about this.


Repository:
  rC Clang

https://reviews.llvm.org/D52676





More information about the cfe-commits mailing list