Skip to content

Commit c41ef75

Browse files
authored
[clang-format] Treat lambda in braced init as inline (#135520)
Fix #125430
1 parent 5f11d64 commit c41ef75

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

+2-1
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

+1
Original file line numberDiff line numberDiff line change
@@ -23722,6 +23722,7 @@ TEST_F(FormatTest, FormatsLambdas) {
2372223722
verifyFormat("function([]() { return b; })", MergeInline);
2372323723
verifyFormat("function([]() { return b; }, a)", MergeInline);
2372423724
verifyFormat("function(a, []() { return b; })", MergeInline);
23725+
verifyFormat("auto guard = foo{[&] { exit_status = true; }};", MergeInline);
2372523726

2372623727
// Check option "BraceWrapping.BeforeLambdaBody" and different state of
2372723728
// AllowShortLambdasOnASingleLine

0 commit comments

Comments
 (0)