Skip to content

Commit d30bf8c

Browse files
owencagithub-actions[bot]
authored andcommitted
Automerge: [clang-format] Treat lambda in braced init as inline (#135520)
Fix #125430
2 parents d3272fe + c41ef75 commit d30bf8c

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
@@ -23719,6 +23719,7 @@ TEST_F(FormatTest, FormatsLambdas) {
2371923719
verifyFormat("function([]() { return b; })", MergeInline);
2372023720
verifyFormat("function([]() { return b; }, a)", MergeInline);
2372123721
verifyFormat("function(a, []() { return b; })", MergeInline);
23722+
verifyFormat("auto guard = foo{[&] { exit_status = true; }};", MergeInline);
2372223723

2372323724
// Check option "BraceWrapping.BeforeLambdaBody" and different state of
2372423725
// AllowShortLambdasOnASingleLine

0 commit comments

Comments
 (0)