diff options
author | Owen Pan <owenpiano@gmail.com> | 2025-04-12 15:06:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-12 15:06:21 -0700 |
commit | 5f744cc6301abb3be5a500b2fcbc944fe2bd3241 (patch) | |
tree | 488c21b611306c56ff91a78a54730ca0858a68f8 /clang/lib/Format/ContinuationIndenter.cpp | |
parent | 09c8cfe219481a8fc20c6711dc5c87451f5a5ef1 (diff) | |
download | llvm-5f744cc6301abb3be5a500b2fcbc944fe2bd3241.zip llvm-5f744cc6301abb3be5a500b2fcbc944fe2bd3241.tar.gz llvm-5f744cc6301abb3be5a500b2fcbc944fe2bd3241.tar.bz2 |
[clang-format] Wrap and indent lambda braces in GNU style (#135479)
Fix #133135
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 11 |
1 files changed, 10 insertions, 1 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. |