@@ -562,7 +562,7 @@ class AnnotatingParser {
562
562
(CurrentToken->is (tok::l_paren) && CurrentToken->Next &&
563
563
CurrentToken->Next ->isOneOf (tok::star, tok::amp, tok::caret));
564
564
if ((CurrentToken->Previous ->isOneOf (tok::kw_const, tok::kw_auto) ||
565
- CurrentToken->Previous ->isSimpleTypeSpecifier ( )) &&
565
+ CurrentToken->Previous ->isTypeName (IsCpp )) &&
566
566
!(CurrentToken->is (tok::l_brace) ||
567
567
(CurrentToken->is (tok::l_paren) && !ProbablyFunctionTypeLParen))) {
568
568
Contexts.back ().IsExpression = false ;
@@ -2573,7 +2573,7 @@ class AnnotatingParser {
2573
2573
return true ;
2574
2574
2575
2575
// MyClass a;
2576
- if (PreviousNotConst->isSimpleTypeSpecifier ( ))
2576
+ if (PreviousNotConst->isTypeName (IsCpp ))
2577
2577
return true ;
2578
2578
2579
2579
// type[] a in Java
@@ -2704,9 +2704,9 @@ class AnnotatingParser {
2704
2704
}
2705
2705
2706
2706
// Heuristically try to determine whether the parentheses contain a type.
2707
- auto IsQualifiedPointerOrReference = [](FormatToken *T) {
2707
+ auto IsQualifiedPointerOrReference = [this ](FormatToken *T) {
2708
2708
// 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" );
2710
2710
// Strip trailing qualifiers such as const or volatile when checking
2711
2711
// whether the parens could be a cast to a pointer/reference type.
2712
2712
while (T) {
@@ -2738,7 +2738,7 @@ class AnnotatingParser {
2738
2738
bool ParensAreType =
2739
2739
!Tok.Previous ||
2740
2740
Tok.Previous ->isOneOf (TT_TemplateCloser, TT_TypeDeclarationParen) ||
2741
- Tok.Previous ->isSimpleTypeSpecifier ( ) ||
2741
+ Tok.Previous ->isTypeName (IsCpp ) ||
2742
2742
IsQualifiedPointerOrReference (Tok.Previous );
2743
2743
bool ParensCouldEndDecl =
2744
2744
Tok.Next ->isOneOf (tok::equal, tok::semi, tok::l_brace, tok::greater);
@@ -3595,7 +3595,8 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
3595
3595
if (!Current.Tok .getIdentifierInfo ())
3596
3596
return false ;
3597
3597
3598
- auto skipOperatorName = [](const FormatToken *Next) -> const FormatToken * {
3598
+ auto skipOperatorName =
3599
+ [IsCpp](const FormatToken *Next) -> const FormatToken * {
3599
3600
for (; Next; Next = Next->Next ) {
3600
3601
if (Next->is (TT_OverloadedOperatorLParen))
3601
3602
return Next;
@@ -3614,7 +3615,7 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
3614
3615
Next = Next->Next ;
3615
3616
continue ;
3616
3617
}
3617
- if ((Next->isSimpleTypeSpecifier ( ) || Next->is (tok::identifier)) &&
3618
+ if ((Next->isTypeName (IsCpp ) || Next->is (tok::identifier)) &&
3618
3619
Next->Next && Next->Next ->isPointerOrReference ()) {
3619
3620
// For operator void*(), operator char*(), operator Foo*().
3620
3621
Next = Next->Next ;
@@ -3712,9 +3713,8 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
3712
3713
Tok = Tok->MatchingParen ;
3713
3714
continue ;
3714
3715
}
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)) {
3718
3718
return true ;
3719
3719
}
3720
3720
if (Tok->isOneOf (tok::l_brace, TT_ObjCMethodExpr) || Tok->Tok .isLiteral ())
@@ -4376,7 +4376,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4376
4376
if (Left.Tok .isLiteral ())
4377
4377
return true ;
4378
4378
// 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 &&
4380
4380
Right.Next ->Next ->is (TT_RangeBasedForLoopColon)) {
4381
4381
return getTokenPointerOrReferenceAlignment (Right) !=
4382
4382
FormatStyle::PAS_Left;
@@ -4419,8 +4419,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4419
4419
if (Right.is (tok::l_brace) && Right.is (BK_Block))
4420
4420
return true ;
4421
4421
// 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)) {
4424
4424
return getTokenPointerOrReferenceAlignment (Left) !=
4425
4425
FormatStyle::PAS_Right;
4426
4426
}
@@ -4458,7 +4458,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4458
4458
if (Right.isPointerOrReference ()) {
4459
4459
const FormatToken *Previous = &Left;
4460
4460
while (Previous && Previous->isNot (tok::kw_operator)) {
4461
- if (Previous->is (tok::identifier) || Previous->isSimpleTypeSpecifier ( )) {
4461
+ if (Previous->is (tok::identifier) || Previous->isTypeName (IsCpp )) {
4462
4462
Previous = Previous->getPreviousNonComment ();
4463
4463
continue ;
4464
4464
}
@@ -4647,7 +4647,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4647
4647
if (!Style .isVerilog () &&
4648
4648
(Left.isOneOf (tok::identifier, tok::greater, tok::r_square,
4649
4649
tok::r_paren) ||
4650
- Left.isSimpleTypeSpecifier ( )) &&
4650
+ Left.isTypeName (IsCpp )) &&
4651
4651
Right.is (tok::l_brace) && Right.getNextNonComment () &&
4652
4652
Right.isNot (BK_Block)) {
4653
4653
return false ;
0 commit comments