@@ -2266,7 +2266,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
22662266 if (!tryToParseLambdaIntroducer ())
22672267 return false ;
22682268
2269- bool SeenArrow = false ;
2269+ FormatToken *Arrow = nullptr ;
22702270 bool InTemplateParameterList = false ;
22712271
22722272 while (FormatTok->isNot (tok::l_brace)) {
@@ -2341,17 +2341,13 @@ bool UnwrappedLineParser::tryToParseLambda() {
23412341 case tok::ellipsis:
23422342 case tok::kw_true:
23432343 case tok::kw_false:
2344- if (SeenArrow || InTemplateParameterList) {
2344+ if (Arrow || InTemplateParameterList) {
23452345 nextToken ();
23462346 break ;
23472347 }
23482348 return true ;
23492349 case tok::arrow:
2350- // This might or might not actually be a lambda arrow (this could be an
2351- // ObjC method invocation followed by a dereferencing arrow). We might
2352- // reset this back to TT_Unknown in TokenAnnotator.
2353- FormatTok->setFinalizedType (TT_LambdaArrow);
2354- SeenArrow = true ;
2350+ Arrow = FormatTok;
23552351 nextToken ();
23562352 break ;
23572353 case tok::kw_requires: {
@@ -2373,6 +2369,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
23732369 FormatTok->setFinalizedType (TT_LambdaLBrace);
23742370 LSquare.setFinalizedType (TT_LambdaLSquare);
23752371
2372+ if (Arrow)
2373+ Arrow->setFinalizedType (TT_LambdaArrow);
2374+
23762375 NestedLambdas.push_back (Line->SeenDecltypeAuto );
23772376 parseChildBlock ();
23782377 assert (!NestedLambdas.empty ());
@@ -2386,11 +2385,6 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
23862385 const FormatToken *LeftSquare = FormatTok;
23872386 nextToken ();
23882387 if (Previous) {
2389- if (Previous->Tok .getIdentifierInfo () &&
2390- !Previous->isOneOf (tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
2391- tok::kw_co_return)) {
2392- return false ;
2393- }
23942388 if (Previous->closesScope ()) {
23952389 // Not a potential C-style cast.
23962390 if (Previous->isNot (tok::r_paren))
@@ -2400,6 +2394,13 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
24002394 // and `int (*)()`.
24012395 if (!BeforeRParen || !BeforeRParen->isOneOf (tok::greater, tok::r_paren))
24022396 return false ;
2397+ } else if (Previous->is (tok::star)) {
2398+ Previous = Previous->getPreviousNonComment ();
2399+ }
2400+ if (Previous && Previous->Tok .getIdentifierInfo () &&
2401+ !Previous->isOneOf (tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
2402+ tok::kw_co_return)) {
2403+ return false ;
24032404 }
24042405 }
24052406 if (LeftSquare->isCppStructuredBinding (IsCpp))
0 commit comments