[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call

Francois JEAN via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 3 01:46:42 PDT 2018

Wawha added inline comments.

Comment at: lib/Format/TokenAnnotator.cpp:627
+    if(Style.BraceWrapping.BeforeLambdaBody && Current->is(TT_LambdaLSquare)) {
+        ++Left->BlockParameterCount;
klimek wrote:
> Why do we want to increase the parameter count here? Specifically, why is it not enough to || this condition to the first is in the function?
I'm not sure to understand. You want to move this test in the first "if" of updateParameterCount()?
Like :

if ((Current->is(tok::l_brace) && Current->BlockKind == BK_Block) ||
 Style.BraceWrapping.BeforeLambdaBody && Current->is(TT_LambdaLSquare))
If it's the case, doing that won't work, because updateParameterCount() is call only for brace, not square, so the condition while be true only once and the BlockParameterCount while be equal to 1.
And ContinuationIndenter::moveStatePastScopeOpener() while require a value greater than 1 to flag true 'HasMultipleNestedBlocks'.
Same for ParameterCount.

I had this code because I was thinking that you want me to have this BlockParameterCount equal to 2 in case a lambda is alone inside a function.

  rC Clang


More information about the cfe-commits mailing list