Skip to content

Commit a10ae6e

Browse files
committed
[clang-format] Treat lambda in braced init as inline
Fix #125430
1 parent 5f744cc commit a10ae6e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5569,7 +5569,8 @@ static bool isAllmanBrace(const FormatToken &Tok) {
55695569
// Returns 'true' if 'Tok' is a function argument.
55705570
static bool IsFunctionArgument(const FormatToken &Tok) {
55715571
return Tok.MatchingParen && Tok.MatchingParen->Next &&
5572-
Tok.MatchingParen->Next->isOneOf(tok::comma, tok::r_paren);
5572+
Tok.MatchingParen->Next->isOneOf(tok::comma, tok::r_paren,
5573+
tok::r_brace);
55735574
}
55745575

55755576
static bool

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23712,6 +23712,7 @@ TEST_F(FormatTest, FormatsLambdas) {
2371223712
verifyFormat("function([]() { return b; })", MergeInline);
2371323713
verifyFormat("function([]() { return b; }, a)", MergeInline);
2371423714
verifyFormat("function(a, []() { return b; })", MergeInline);
23715+
verifyFormat("auto guard = foo{[&] { exit_status = true; }};", MergeInline);
2371523716

2371623717
// Check option "BraceWrapping.BeforeLambdaBody" and different state of
2371723718
// AllowShortLambdasOnASingleLine

0 commit comments

Comments
 (0)