@@ -2268,7 +2268,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
2268
2268
if (!tryToParseLambdaIntroducer ())
2269
2269
return false ;
2270
2270
2271
- bool SeenArrow = false ;
2271
+ FormatToken *Arrow = nullptr ;
2272
2272
bool InTemplateParameterList = false ;
2273
2273
2274
2274
while (FormatTok->isNot (tok::l_brace)) {
@@ -2343,17 +2343,13 @@ bool UnwrappedLineParser::tryToParseLambda() {
2343
2343
case tok::ellipsis:
2344
2344
case tok::kw_true:
2345
2345
case tok::kw_false:
2346
- if (SeenArrow || InTemplateParameterList) {
2346
+ if (Arrow || InTemplateParameterList) {
2347
2347
nextToken ();
2348
2348
break ;
2349
2349
}
2350
2350
return true ;
2351
2351
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;
2357
2353
nextToken ();
2358
2354
break ;
2359
2355
case tok::kw_requires: {
@@ -2375,6 +2371,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
2375
2371
FormatTok->setFinalizedType (TT_LambdaLBrace);
2376
2372
LSquare.setFinalizedType (TT_LambdaLSquare);
2377
2373
2374
+ if (Arrow)
2375
+ Arrow->setFinalizedType (TT_LambdaArrow);
2376
+
2378
2377
NestedLambdas.push_back (Line->SeenDecltypeAuto );
2379
2378
parseChildBlock ();
2380
2379
assert (!NestedLambdas.empty ());
@@ -2388,11 +2387,6 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
2388
2387
const FormatToken *LeftSquare = FormatTok;
2389
2388
nextToken ();
2390
2389
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
- }
2396
2390
if (Previous->closesScope ()) {
2397
2391
// Not a potential C-style cast.
2398
2392
if (Previous->isNot (tok::r_paren))
@@ -2402,6 +2396,13 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
2402
2396
// and `int (*)()`.
2403
2397
if (!BeforeRParen || !BeforeRParen->isOneOf (tok::greater, tok::r_paren))
2404
2398
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 ;
2405
2406
}
2406
2407
}
2407
2408
if (LeftSquare->isCppStructuredBinding (IsCpp))
0 commit comments