@@ -562,7 +562,7 @@ class AnnotatingParser {
562562 (CurrentToken->is (tok::l_paren) && CurrentToken->Next &&
563563 CurrentToken->Next ->isOneOf (tok::star, tok::amp, tok::caret));
564564 if ((CurrentToken->Previous ->isOneOf (tok::kw_const, tok::kw_auto) ||
565- CurrentToken->Previous ->isSimpleTypeSpecifier ( )) &&
565+ CurrentToken->Previous ->isTypeName (IsCpp )) &&
566566 !(CurrentToken->is (tok::l_brace) ||
567567 (CurrentToken->is (tok::l_paren) && !ProbablyFunctionTypeLParen))) {
568568 Contexts.back ().IsExpression = false ;
@@ -2573,7 +2573,7 @@ class AnnotatingParser {
25732573 return true ;
25742574
25752575 // MyClass a;
2576- if (PreviousNotConst->isSimpleTypeSpecifier ( ))
2576+ if (PreviousNotConst->isTypeName (IsCpp ))
25772577 return true ;
25782578
25792579 // type[] a in Java
@@ -2704,9 +2704,9 @@ class AnnotatingParser {
27042704 }
27052705
27062706 // Heuristically try to determine whether the parentheses contain a type.
2707- auto IsQualifiedPointerOrReference = [](FormatToken *T) {
2707+ auto IsQualifiedPointerOrReference = [this ](FormatToken *T) {
27082708 // This is used to handle cases such as x = (foo *const)&y;
2709- assert (!T->isSimpleTypeSpecifier ( ) && " Should have already been checked" );
2709+ assert (!T->isTypeName (IsCpp ) && " Should have already been checked" );
27102710 // Strip trailing qualifiers such as const or volatile when checking
27112711 // whether the parens could be a cast to a pointer/reference type.
27122712 while (T) {
@@ -2738,7 +2738,7 @@ class AnnotatingParser {
27382738 bool ParensAreType =
27392739 !Tok.Previous ||
27402740 Tok.Previous ->isOneOf (TT_TemplateCloser, TT_TypeDeclarationParen) ||
2741- Tok.Previous ->isSimpleTypeSpecifier ( ) ||
2741+ Tok.Previous ->isTypeName (IsCpp ) ||
27422742 IsQualifiedPointerOrReference (Tok.Previous );
27432743 bool ParensCouldEndDecl =
27442744 Tok.Next ->isOneOf (tok::equal, tok::semi, tok::l_brace, tok::greater);
@@ -3595,7 +3595,8 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
35953595 if (!Current.Tok .getIdentifierInfo ())
35963596 return false ;
35973597
3598- auto skipOperatorName = [](const FormatToken *Next) -> const FormatToken * {
3598+ auto skipOperatorName =
3599+ [IsCpp](const FormatToken *Next) -> const FormatToken * {
35993600 for (; Next; Next = Next->Next ) {
36003601 if (Next->is (TT_OverloadedOperatorLParen))
36013602 return Next;
@@ -3614,7 +3615,7 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
36143615 Next = Next->Next ;
36153616 continue ;
36163617 }
3617- if ((Next->isSimpleTypeSpecifier ( ) || Next->is (tok::identifier)) &&
3618+ if ((Next->isTypeName (IsCpp ) || Next->is (tok::identifier)) &&
36183619 Next->Next && Next->Next ->isPointerOrReference ()) {
36193620 // For operator void*(), operator char*(), operator Foo*().
36203621 Next = Next->Next ;
@@ -3712,9 +3713,8 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
37123713 Tok = Tok->MatchingParen ;
37133714 continue ;
37143715 }
3715- if (Tok->is (tok::kw_const) || Tok->isSimpleTypeSpecifier () ||
3716- Tok->isOneOf (TT_PointerOrReference, TT_StartOfName, tok::ellipsis,
3717- TT_TypeName)) {
3716+ if (Tok->is (tok::kw_const) || Tok->isTypeName (IsCpp) ||
3717+ Tok->isOneOf (TT_PointerOrReference, TT_StartOfName, tok::ellipsis)) {
37183718 return true ;
37193719 }
37203720 if (Tok->isOneOf (tok::l_brace, TT_ObjCMethodExpr) || Tok->Tok .isLiteral ())
@@ -4376,7 +4376,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
43764376 if (Left.Tok .isLiteral ())
43774377 return true ;
43784378 // for (auto a = 0, b = 0; const auto & c : {1, 2, 3})
4379- if (Left.isTypeOrIdentifier () && Right.Next && Right.Next ->Next &&
4379+ if (Left.isTypeOrIdentifier (IsCpp ) && Right.Next && Right.Next ->Next &&
43804380 Right.Next ->Next ->is (TT_RangeBasedForLoopColon)) {
43814381 return getTokenPointerOrReferenceAlignment (Right) !=
43824382 FormatStyle::PAS_Left;
@@ -4419,8 +4419,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
44194419 if (Right.is (tok::l_brace) && Right.is (BK_Block))
44204420 return true ;
44214421 // for (auto a = 0, b = 0; const auto& c : {1, 2, 3})
4422- if (Left.Previous && Left.Previous ->isTypeOrIdentifier () && Right. Next &&
4423- Right.Next ->is (TT_RangeBasedForLoopColon)) {
4422+ if (Left.Previous && Left.Previous ->isTypeOrIdentifier (IsCpp) &&
4423+ Right.Next && Right. Next ->is (TT_RangeBasedForLoopColon)) {
44244424 return getTokenPointerOrReferenceAlignment (Left) !=
44254425 FormatStyle::PAS_Right;
44264426 }
@@ -4458,7 +4458,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
44584458 if (Right.isPointerOrReference ()) {
44594459 const FormatToken *Previous = &Left;
44604460 while (Previous && Previous->isNot (tok::kw_operator)) {
4461- if (Previous->is (tok::identifier) || Previous->isSimpleTypeSpecifier ( )) {
4461+ if (Previous->is (tok::identifier) || Previous->isTypeName (IsCpp )) {
44624462 Previous = Previous->getPreviousNonComment ();
44634463 continue ;
44644464 }
@@ -4647,7 +4647,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
46474647 if (!Style.isVerilog () &&
46484648 (Left.isOneOf (tok::identifier, tok::greater, tok::r_square,
46494649 tok::r_paren) ||
4650- Left.isSimpleTypeSpecifier ( )) &&
4650+ Left.isTypeName (IsCpp )) &&
46514651 Right.is (tok::l_brace) && Right.getNextNonComment () &&
46524652 Right.isNot (BK_Block)) {
46534653 return false ;
0 commit comments