diff options
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 39eb706..55e1d1c 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1334,6 +1334,14 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { Style.IndentWidth; } + if (Style.BraceWrapping.BeforeLambdaBody && + Style.BraceWrapping.IndentBraces && Current.is(TT_LambdaLBrace)) { + const auto From = Style.LambdaBodyIndentation == FormatStyle::LBI_Signature + ? CurrentState.Indent + : State.FirstIndent; + return From + Style.IndentWidth; + } + if ((NextNonComment->is(tok::l_brace) && NextNonComment->is(BK_Block)) || (Style.isVerilog() && Keywords.isVerilogBegin(*NextNonComment))) { if (Current.NestingLevel == 0 || @@ -2113,7 +2121,8 @@ void ContinuationIndenter::moveStateToNewBlock(LineState &State, bool NewLine) { if (Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope && State.NextToken->is(TT_LambdaLBrace) && !State.Line->MightBeFunctionDecl) { - State.Stack.back().NestedBlockIndent = State.FirstIndent; + const auto Indent = Style.IndentWidth * Style.BraceWrapping.IndentBraces; + State.Stack.back().NestedBlockIndent = State.FirstIndent + Indent; } unsigned NestedBlockIndent = State.Stack.back().NestedBlockIndent; // ObjC block sometimes follow special indentation rules. diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 3802766..c601967 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1435,7 +1435,7 @@ static void expandPresetsBraceWrapping(FormatStyle &Expanded) { /*AfterExternBlock=*/true, /*BeforeCatch=*/true, /*BeforeElse=*/true, - /*BeforeLambdaBody=*/false, + /*BeforeLambdaBody=*/true, /*BeforeWhile=*/true, /*IndentBraces=*/true, /*SplitEmptyFunction=*/true, |