@@ -2268,7 +2268,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
22682268 if (!tryToParseLambdaIntroducer ())
22692269 return false ;
22702270
2271- bool SeenArrow = false ;
2271+ FormatToken *Arrow = nullptr ;
22722272 bool InTemplateParameterList = false ;
22732273
22742274 while (FormatTok->isNot (tok::l_brace)) {
@@ -2343,17 +2343,13 @@ bool UnwrappedLineParser::tryToParseLambda() {
23432343 case tok::ellipsis:
23442344 case tok::kw_true:
23452345 case tok::kw_false:
2346- if (SeenArrow || InTemplateParameterList) {
2346+ if (Arrow || InTemplateParameterList) {
23472347 nextToken ();
23482348 break ;
23492349 }
23502350 return true ;
23512351 case tok::arrow:
2352- // This might or might not actually be a lambda arrow (this could be an
2353- // ObjC method invocation followed by a dereferencing arrow). We might
2354- // reset this back to TT_Unknown in TokenAnnotator.
2355- FormatTok->setFinalizedType (TT_LambdaArrow);
2356- SeenArrow = true ;
2352+ Arrow = FormatTok;
23572353 nextToken ();
23582354 break ;
23592355 case tok::kw_requires: {
@@ -2375,6 +2371,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
23752371 FormatTok->setFinalizedType (TT_LambdaLBrace);
23762372 LSquare.setFinalizedType (TT_LambdaLSquare);
23772373
2374+ if (Arrow)
2375+ Arrow->setFinalizedType (TT_LambdaArrow);
2376+
23782377 NestedLambdas.push_back (Line->SeenDecltypeAuto );
23792378 parseChildBlock ();
23802379 assert (!NestedLambdas.empty ());
@@ -2388,11 +2387,6 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
23882387 const FormatToken *LeftSquare = FormatTok;
23892388 nextToken ();
23902389 if (Previous) {
2391- if (Previous->Tok .getIdentifierInfo () &&
2392- !Previous->isOneOf (tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
2393- tok::kw_co_return)) {
2394- return false ;
2395- }
23962390 if (Previous->closesScope ()) {
23972391 // Not a potential C-style cast.
23982392 if (Previous->isNot (tok::r_paren))
@@ -2402,6 +2396,13 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
24022396 // and `int (*)()`.
24032397 if (!BeforeRParen || !BeforeRParen->isOneOf (tok::greater, tok::r_paren))
24042398 return false ;
2399+ } else if (Previous->is (tok::star)) {
2400+ Previous = Previous->getPreviousNonComment ();
2401+ }
2402+ if (Previous && Previous->Tok .getIdentifierInfo () &&
2403+ !Previous->isOneOf (tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
2404+ tok::kw_co_return)) {
2405+ return false ;
24052406 }
24062407 }
24072408 if (LeftSquare->isCppStructuredBinding (IsCpp))
0 commit comments