@@ -468,16 +468,18 @@ class AnnotatingParser {
468
468
OpeningParen.Previous && OpeningParen.Previous ->is (tok::kw_for);
469
469
FormatToken *PossibleObjCForInToken = nullptr ;
470
470
while (CurrentToken) {
471
- if ( CurrentToken->Previous -> is (TT_PointerOrReference) &&
472
- CurrentToken-> Previous -> Previous -> isOneOf (tok::l_paren,
473
- tok::coloncolon)) {
471
+ const auto &Prev = * CurrentToken->Previous ;
472
+ if (Prev. is (TT_PointerOrReference) &&
473
+ Prev. Previous -> isOneOf (tok::l_paren, tok::coloncolon)) {
474
474
ProbablyFunctionType = true ;
475
475
}
476
476
if (CurrentToken->is (tok::comma))
477
477
MightBeFunctionType = false ;
478
- if (CurrentToken-> Previous -> is (TT_BinaryOperator))
478
+ if (Prev. is (TT_BinaryOperator))
479
479
Contexts.back ().IsExpression = true ;
480
480
if (CurrentToken->is (tok::r_paren)) {
481
+ if (Prev.is (TT_PointerOrReference) && Prev.Previous == &OpeningParen)
482
+ MightBeFunctionType = true ;
481
483
if (OpeningParen.isNot (TT_CppCastLParen) && MightBeFunctionType &&
482
484
ProbablyFunctionType && CurrentToken->Next &&
483
485
(CurrentToken->Next ->is (tok::l_paren) ||
@@ -550,8 +552,8 @@ class AnnotatingParser {
550
552
bool ProbablyFunctionTypeLParen =
551
553
(CurrentToken->is (tok::l_paren) && CurrentToken->Next &&
552
554
CurrentToken->Next ->isOneOf (tok::star, tok::amp, tok::caret));
553
- if ((CurrentToken-> Previous -> isOneOf (tok::kw_const, tok::kw_auto) ||
554
- CurrentToken-> Previous -> isTypeName (LangOpts)) &&
555
+ if ((Prev. isOneOf (tok::kw_const, tok::kw_auto) ||
556
+ Prev. isTypeName (LangOpts)) &&
555
557
!(CurrentToken->is (tok::l_brace) ||
556
558
(CurrentToken->is (tok::l_paren) && !ProbablyFunctionTypeLParen))) {
557
559
Contexts.back ().IsExpression = false ;
0 commit comments