@@ -300,7 +300,7 @@ class AnnotatingParser {
300
300
return false ;
301
301
}
302
302
303
- bool parseParens (bool LookForDecls = false ) {
303
+ bool parseParens (bool IsIf = false ) {
304
304
if (!CurrentToken)
305
305
return false ;
306
306
assert (CurrentToken->Previous && " Unknown previous token" );
@@ -468,24 +468,6 @@ class AnnotatingParser {
468
468
OpeningParen.Previous && OpeningParen.Previous ->is (tok::kw_for);
469
469
FormatToken *PossibleObjCForInToken = nullptr ;
470
470
while (CurrentToken) {
471
- // LookForDecls is set when "if (" has been seen. Check for
472
- // 'identifier' '*' 'identifier' followed by not '=' -- this
473
- // '*' has to be a binary operator but determineStarAmpUsage() will
474
- // categorize it as an unary operator, so set the right type here.
475
- if (LookForDecls && CurrentToken->Next ) {
476
- FormatToken *Prev = CurrentToken->getPreviousNonComment ();
477
- if (Prev) {
478
- FormatToken *PrevPrev = Prev->getPreviousNonComment ();
479
- FormatToken *Next = CurrentToken->Next ;
480
- if (PrevPrev && PrevPrev->is (tok::identifier) &&
481
- PrevPrev->isNot (TT_TypeName) && Prev->isPointerOrReference () &&
482
- CurrentToken->is (tok::identifier) && Next->isNot (tok::equal)) {
483
- Prev->setType (TT_BinaryOperator);
484
- LookForDecls = false ;
485
- }
486
- }
487
- }
488
-
489
471
if (CurrentToken->Previous ->is (TT_PointerOrReference) &&
490
472
CurrentToken->Previous ->Previous ->isOneOf (tok::l_paren,
491
473
tok::coloncolon)) {
@@ -581,6 +563,15 @@ class AnnotatingParser {
581
563
PossibleObjCForInToken = nullptr ;
582
564
}
583
565
}
566
+ if (IsIf && CurrentToken->is (tok::semi)) {
567
+ for (auto *Tok = OpeningParen.Next ;
568
+ Tok != CurrentToken &&
569
+ !Tok->isOneOf (tok::equal, tok::l_paren, tok::l_brace);
570
+ Tok = Tok->Next ) {
571
+ if (Tok->isPointerOrReference ())
572
+ Tok->setFinalizedType (TT_PointerOrReference);
573
+ }
574
+ }
584
575
if (MightBeObjCForRangeLoop && CurrentToken->is (Keywords.kw_in )) {
585
576
PossibleObjCForInToken = CurrentToken;
586
577
PossibleObjCForInToken->setType (TT_ObjCForIn);
@@ -1307,7 +1298,7 @@ class AnnotatingParser {
1307
1298
// Multi-line string itself is a single annotated token.
1308
1299
if (Tok->is (TT_TableGenMultiLineString))
1309
1300
return true ;
1310
- switch (Tok->Tok .getKind ()) {
1301
+ switch (bool IsIf = false ; Tok->Tok .getKind ()) {
1311
1302
case tok::plus:
1312
1303
case tok::minus:
1313
1304
if (!Tok->Previous && Line.MustBeDeclaration )
@@ -1467,11 +1458,12 @@ class AnnotatingParser {
1467
1458
CurrentToken->isOneOf (tok::kw_constexpr, tok::identifier)) {
1468
1459
next ();
1469
1460
}
1461
+ IsIf = true ;
1470
1462
[[fallthrough]];
1471
1463
case tok::kw_while:
1472
1464
if (CurrentToken && CurrentToken->is (tok::l_paren)) {
1473
1465
next ();
1474
- if (!parseParens (/* LookForDecls= */ true ))
1466
+ if (!parseParens (IsIf ))
1475
1467
return false ;
1476
1468
}
1477
1469
break ;
0 commit comments