[PATCH] D44609: [Clang-Format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

Francois JEAN via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 20 00:54:03 PDT 2019


Wawha updated this revision to Diff 216061.
Wawha added a comment.
Herald added a subscriber: ormris.

I update the patch for the last version of clang format, especially since option "AllowShortLambdasOnASingleLine" has been added (which require more change for this patch).
Indeed, for AllowShortLambdasOnASingleLine patch (https://reviews.llvm.org/D57687), the isAllmanBrace() function has been changed (adding TT_LambdaLBrace) which require more test to handle break for lambda body.

Unfortunately, there is one case I'm not able to handle correctly for the moment.
With option "BeforeLambdaBody : true", "AllowShortLambdasOnASingleLine : SLS_All;" and "BinPackParameters : false", the expected code below:

  FctWithLonglineInLambda(
    param,
    []()
    {
      return HereAVeryLongLineThatWillBeFormattedOnMultipleLineAndShouldNotBeConsiderAsInline;
    });

Is formatted like this with the current patch:

  FctWithLonglineInLambda(param, []() {
      return HereAVeryLongLineThatWillBeFormattedOnMultipleLineAndShouldNotBeConsiderAsInline;
    });

Can someone help me and tell where to look to set break for parameters (and lambda) when the whole parameters line (included the lambda body, which is not the case actually) do not fit the inside one line.
Before the AllowShortLambdasOnASingleLine option, there is no need for that, due to the fact that the lambda was always break. But with this new option, we need to handle that too.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D44609/new/

https://reviews.llvm.org/D44609

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp





More information about the cfe-commits mailing list