Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Format/ContinuationIndenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
Style.IndentWidth;
}

if (Style.BraceWrapping.BeforeLambdaBody &&
Style.BraceWrapping.IndentBraces && Current.is(TT_LambdaLBrace)) {
return CurrentState.Indent + Style.IndentWidth;
}

if ((NextNonComment->is(tok::l_brace) && NextNonComment->is(BK_Block)) ||
(Style.isVerilog() && Keywords.isVerilogBegin(*NextNonComment))) {
if (Current.NestingLevel == 0 ||
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24268,6 +24268,15 @@ TEST_F(FormatTest, EmptyLinesInLambdas) {
"};");
}

TEST_F(FormatTest, LambdaBracesInGNU) {
verifyFormat("auto x = [&] ()\n"
" {\n"
" for (int i = 0; i < y; ++i)\n"
" return 97;\n"
" };",
getGNUStyle());
}

TEST_F(FormatTest, FormatsBlocks) {
FormatStyle ShortBlocks = getLLVMStyle();
ShortBlocks.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
Expand Down