@@ -377,7 +377,7 @@ class AnnotatingParser {
377
377
// detected one yet.
378
378
if (PrevNonComment && OpeningParen.is (TT_Unknown)) {
379
379
if (PrevNonComment->is (tok::kw___attribute)) {
380
- OpeningParen.setType (TT_AttributeParen );
380
+ OpeningParen.setType (TT_AttributeLParen );
381
381
} else if (PrevNonComment->isOneOf (TT_TypenameMacro, tok::kw_decltype,
382
382
tok::kw_typeof,
383
383
#define TRANSFORM_TYPE_TRAIT_DEF (_, Trait ) tok::kw___##Trait,
@@ -475,8 +475,8 @@ class AnnotatingParser {
475
475
}
476
476
}
477
477
478
- if (OpeningParen.is (TT_AttributeParen ))
479
- CurrentToken->setType (TT_AttributeParen );
478
+ if (OpeningParen.is (TT_AttributeLParen ))
479
+ CurrentToken->setType (TT_AttributeRParen );
480
480
if (OpeningParen.is (TT_TypeDeclarationParen))
481
481
CurrentToken->setType (TT_TypeDeclarationParen);
482
482
if (OpeningParen.Previous &&
@@ -2382,11 +2382,15 @@ class AnnotatingParser {
2382
2382
// Strip trailing qualifiers such as const or volatile when checking
2383
2383
// whether the parens could be a cast to a pointer/reference type.
2384
2384
while (T) {
2385
- if (T->is (TT_AttributeParen )) {
2385
+ if (T->is (TT_AttributeRParen )) {
2386
2386
// Handle `x = (foo *__attribute__((foo)))&v;`:
2387
- if (T->MatchingParen && T->MatchingParen ->Previous &&
2388
- T->MatchingParen ->Previous ->is (tok::kw___attribute)) {
2389
- T = T->MatchingParen ->Previous ->Previous ;
2387
+ assert (T->is (tok::r_paren));
2388
+ assert (T->MatchingParen );
2389
+ assert (T->MatchingParen ->is (tok::l_paren));
2390
+ assert (T->MatchingParen ->is (TT_AttributeLParen));
2391
+ if (const auto *Tok = T->MatchingParen ->Previous ;
2392
+ Tok && Tok->is (tok::kw___attribute)) {
2393
+ T = Tok->Previous ;
2390
2394
continue ;
2391
2395
}
2392
2396
} else if (T->is (TT_AttributeSquare)) {
@@ -3989,7 +3993,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
3989
3993
// after pointer qualifiers.
3990
3994
if ((Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_After ||
3991
3995
Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
3992
- (Left.is (TT_AttributeParen ) ||
3996
+ (Left.is (TT_AttributeRParen ) ||
3993
3997
Left.canBePointerOrReferenceQualifier ())) {
3994
3998
return true ;
3995
3999
}
@@ -4182,7 +4186,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4182
4186
return Style.SpaceBeforeParensOptions .AfterRequiresInExpression ||
4183
4187
spaceRequiredBeforeParens (Right);
4184
4188
}
4185
- if (( Left.is (tok::r_paren) && Left. is (TT_AttributeParen) ) ||
4189
+ if (Left.is (TT_AttributeRParen ) ||
4186
4190
(Left.is (tok::r_square) && Left.is (TT_AttributeSquare))) {
4187
4191
return true ;
4188
4192
}
@@ -4361,7 +4365,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
4361
4365
return false ;
4362
4366
}
4363
4367
// Space in __attribute__((attr)) ::type.
4364
- if (Left.is (TT_AttributeParen ) && Right.is (tok::coloncolon))
4368
+ if (Left.is (TT_AttributeRParen ) && Right.is (tok::coloncolon))
4365
4369
return true ;
4366
4370
4367
4371
if (Left.is (tok::kw_operator))
@@ -5190,7 +5194,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5190
5194
}
5191
5195
5192
5196
// Ensure wrapping after __attribute__((XX)) and @interface etc.
5193
- if (Left.is (TT_AttributeParen ) && Right.is (TT_ObjCDecl))
5197
+ if (Left.is (TT_AttributeRParen ) && Right.is (TT_ObjCDecl))
5194
5198
return true ;
5195
5199
5196
5200
if (Left.is (TT_LambdaLBrace)) {
@@ -5552,8 +5556,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
5552
5556
!Style.Cpp11BracedListStyle ) {
5553
5557
return false ;
5554
5558
}
5555
- if (Left.is (tok::l_paren) &&
5556
- Left.isOneOf (TT_AttributeParen, TT_TypeDeclarationParen)) {
5559
+ if (Left.is (TT_AttributeLParen) ||
5560
+ ( Left.is (tok::l_paren) && Left. is ( TT_TypeDeclarationParen) )) {
5557
5561
return false ;
5558
5562
}
5559
5563
if (Left.is (tok::l_paren) && Left.Previous &&
0 commit comments