@@ -531,10 +531,6 @@ class AnnotatingParser {
531531            OpeningParen.Previous ->is (TT_LeadingJavaAnnotation)) {
532532          CurrentToken->setType (TT_LeadingJavaAnnotation);
533533        }
534-         if  (OpeningParen.Previous  &&
535-             OpeningParen.Previous ->is (TT_AttributeSquare)) {
536-           CurrentToken->setType (TT_AttributeSquare);
537-         }
538534
539535        if  (!HasMultipleLines)
540536          OpeningParen.setPackingKind (PPK_Inconclusive);
@@ -722,9 +718,11 @@ class AnnotatingParser {
722718      } else  if  (InsideInlineASM) {
723719        Left->setType (TT_InlineASMSymbolicNameLSquare);
724720      } else  if  (IsCpp11AttributeSpecifier) {
725-         Left->setType (TT_AttributeSquare);
726-         if  (!IsInnerSquare && Left->Previous )
727-           Left->Previous ->EndsCppAttributeGroup  = false ;
721+         if  (!IsInnerSquare) {
722+           Left->setType (TT_AttributeLSquare);
723+           if  (Left->Previous )
724+             Left->Previous ->EndsCppAttributeGroup  = false ;
725+         }
728726      } else  if  (Style.isJavaScript () && Parent &&
729727                 Contexts.back ().ContextKind  == tok::l_brace &&
730728                 Parent->isOneOf (tok::l_brace, tok::comma)) {
@@ -733,7 +731,7 @@ class AnnotatingParser {
733731                 Parent && Parent->isOneOf (tok::l_brace, tok::comma)) {
734732        Left->setType (TT_DesignatedInitializerLSquare);
735733      } else  if  (IsCSharpAttributeSpecifier) {
736-         Left->setType (TT_AttributeSquare );
734+         Left->setType (TT_AttributeLSquare );
737735      } else  if  (CurrentToken->is (tok::r_square) && Parent &&
738736                 Parent->is (TT_TemplateCloser)) {
739737        Left->setType (TT_ArraySubscriptLSquare);
@@ -797,13 +795,12 @@ class AnnotatingParser {
797795
798796    while  (CurrentToken) {
799797      if  (CurrentToken->is (tok::r_square)) {
800-         if  (IsCpp11AttributeSpecifier) {
801-           CurrentToken->setType (TT_AttributeSquare);
802-           if  (!IsInnerSquare)
803-             CurrentToken->EndsCppAttributeGroup  = true ;
798+         if  (IsCpp11AttributeSpecifier && !IsInnerSquare) {
799+           CurrentToken->setType (TT_AttributeRSquare);
800+           CurrentToken->EndsCppAttributeGroup  = true ;
804801        }
805802        if  (IsCSharpAttributeSpecifier) {
806-           CurrentToken->setType (TT_AttributeSquare );
803+           CurrentToken->setType (TT_AttributeRSquare );
807804        } else  if  (((CurrentToken->Next  &&
808805                     CurrentToken->Next ->is (tok::l_paren)) ||
809806                    (CurrentToken->Previous  &&
@@ -1297,7 +1294,7 @@ class AnnotatingParser {
12971294  bool  consumeToken () {
12981295    if  (IsCpp) {
12991296      const  auto  *Prev = CurrentToken->getPreviousNonComment ();
1300-       if  (Prev && Prev->is (tok::r_square) && Prev-> is (TT_AttributeSquare ) &&
1297+       if  (Prev && Prev->is (TT_AttributeRSquare ) &&
13011298          CurrentToken->isOneOf (tok::kw_if, tok::kw_switch, tok::kw_case,
13021299                                tok::kw_default, tok::kw_for, tok::kw_while) &&
13031300          mustBreakAfterAttributes (*CurrentToken, Style)) {
@@ -2850,7 +2847,7 @@ class AnnotatingParser {
28502847            T = Tok->Previous ;
28512848            continue ;
28522849          }
2853-         } else  if  (T->is (TT_AttributeSquare )) {
2850+         } else  if  (T->is (TT_AttributeRSquare )) {
28542851          //  Handle `x = (foo *[[clang::foo]])&v;`:
28552852          if  (T->MatchingParen  && T->MatchingParen ->Previous ) {
28562853            T = T->MatchingParen ->Previous ;
@@ -3656,7 +3653,7 @@ static FormatToken *getFunctionName(const AnnotatedLine &Line,
36563653  for  (FormatToken *Tok = Line.getFirstNonComment (), *Name = nullptr ; Tok;
36573654       Tok = Tok->getNextNonComment ()) {
36583655    //  Skip C++11 attributes both before and after the function name.
3659-     if  (Tok->is (tok::l_square) && Tok-> is (TT_AttributeSquare )) {
3656+     if  (Tok->is (TT_AttributeLSquare )) {
36603657      Tok = Tok->MatchingParen ;
36613658      if  (!Tok)
36623659        break ;
@@ -4325,7 +4322,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
43254322      return  35 ;
43264323    if  (Right.isNoneOf (TT_ObjCMethodExpr, TT_LambdaLSquare,
43274324                       TT_ArrayInitializerLSquare,
4328-                        TT_DesignatedInitializerLSquare, TT_AttributeSquare )) {
4325+                        TT_DesignatedInitializerLSquare, TT_AttributeLSquare )) {
43294326      return  500 ;
43304327    }
43314328  }
@@ -4808,7 +4805,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48084805  if  (Right.is (tok::l_square) &&
48094806      Right.isNoneOf (TT_ObjCMethodExpr, TT_LambdaLSquare,
48104807                     TT_DesignatedInitializerLSquare,
4811-                      TT_StructuredBindingLSquare, TT_AttributeSquare ) &&
4808+                      TT_StructuredBindingLSquare, TT_AttributeLSquare ) &&
48124809      Left.isNoneOf (tok::numeric_constant, TT_DictLiteral) &&
48134810      !(Left.isNot (tok::r_square) && Style.SpaceBeforeSquareBrackets  &&
48144811        Right.is (TT_ArraySubscriptLSquare))) {
@@ -4827,7 +4824,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48274824
48284825  //  Space between template and attribute.
48294826  //  e.g. template <typename T> [[nodiscard]] ...
4830-   if  (Left.is (TT_TemplateCloser) && Right.is (TT_AttributeSquare ))
4827+   if  (Left.is (TT_TemplateCloser) && Right.is (TT_AttributeLSquare ))
48314828    return  true ;
48324829  //  Space before parentheses common for all languages
48334830  if  (Right.is (tok::l_paren)) {
@@ -4842,10 +4839,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48424839      return  Style.SpaceBeforeParensOptions .AfterRequiresInExpression  ||
48434840             spaceRequiredBeforeParens (Right);
48444841    }
4845-     if  (Left.is (TT_AttributeRParen) ||
4846-         (Left.is (tok::r_square) && Left.is (TT_AttributeSquare))) {
4842+     if  (Left.isOneOf (TT_AttributeRParen, TT_AttributeRSquare))
48474843      return  true ;
4848-     }
48494844    if  (Left.is (TT_ForEachMacro)) {
48504845      return  Style.SpaceBeforeParensOptions .AfterForeachMacros  ||
48514846             spaceRequiredBeforeParens (Right);
@@ -5663,16 +5658,14 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
56635658    }
56645659
56655660    //  Break after C# [...] and before public/protected/private/internal.
5666-     if  (Left.is (TT_AttributeSquare) && Left. is (tok::r_square ) &&
5661+     if  (Left.is (TT_AttributeRSquare ) &&
56675662        (Right.isAccessSpecifier (/* ColonRequired=*/ false ) ||
56685663         Right.is (Keywords.kw_internal ))) {
56695664      return  true ;
56705665    }
56715666    //  Break between ] and [ but only when there are really 2 attributes.
5672-     if  (Left.is (TT_AttributeSquare) && Right.is (TT_AttributeSquare) &&
5673-         Left.is (tok::r_square) && Right.is (tok::l_square)) {
5667+     if  (Left.is (TT_AttributeRSquare) && Right.is (TT_AttributeLSquare))
56745668      return  true ;
5675-     }
56765669  } else  if  (Style.isJavaScript ()) {
56775670    //  FIXME: This might apply to other languages and token kinds.
56785671    if  (Right.is (tok::string_literal) && Left.is (tok::plus) && BeforeLeft &&
@@ -6412,8 +6405,10 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
64126405  if  (Right.isAttribute ())
64136406    return  true ;
64146407
6415-   if  (Right.is (tok::l_square) && Right.is (TT_AttributeSquare))
6416-     return  Left.isNot (TT_AttributeSquare);
6408+   if  (Right.is (TT_AttributeLSquare)) {
6409+     assert (Left.isNot (tok::l_square));
6410+     return  true ;
6411+   }
64176412
64186413  if  (Left.is (tok::identifier) && Right.is (tok::string_literal))
64196414    return  true ;
@@ -6454,8 +6449,12 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
64546449       Left.getPrecedence () == prec::Assignment)) {
64556450    return  true ;
64566451  }
6457-   if  ((Left.is (TT_AttributeSquare) && Right.is (tok::l_square)) ||
6458-       (Left.is (tok::r_square) && Right.is (TT_AttributeSquare))) {
6452+   if  (Left.is (TT_AttributeLSquare) && Right.is (tok::l_square)) {
6453+     assert (Right.isNot (TT_AttributeLSquare));
6454+     return  false ;
6455+   }
6456+   if  (Left.is (tok::r_square) && Right.is (TT_AttributeRSquare)) {
6457+     assert (Left.isNot (TT_AttributeRSquare));
64596458    return  false ;
64606459  }
64616460
0 commit comments