@@ -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)) {
@@ -3993,7 +3997,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
3993
3997
// after pointer qualifiers.
3994
3998
if ((Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_After ||
3995
3999
Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
3996
- (Left.is (TT_AttributeParen ) ||
4000
+ (Left.is (TT_AttributeRParen ) ||
3997
4001
Left.canBePointerOrReferenceQualifier ())) {
3998
4002
return true ;
3999
4003
}
@@ -4186,7 +4190,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4186
4190
return Style.SpaceBeforeParensOptions .AfterRequiresInExpression ||
4187
4191
spaceRequiredBeforeParens (Right);
4188
4192
}
4189
- if (( Left.is (tok::r_paren) && Left. is (TT_AttributeParen) ) ||
4193
+ if (Left.is (TT_AttributeRParen ) ||
4190
4194
(Left.is (tok::r_square) && Left.is (TT_AttributeSquare))) {
4191
4195
return true ;
4192
4196
}
@@ -4365,7 +4369,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
4365
4369
return false ;
4366
4370
}
4367
4371
// Space in __attribute__((attr)) ::type.
4368
- if (Left.is (TT_AttributeParen ) && Right.is (tok::coloncolon))
4372
+ if (Left.is (TT_AttributeRParen ) && Right.is (tok::coloncolon))
4369
4373
return true ;
4370
4374
4371
4375
if (Left.is (tok::kw_operator))
@@ -5194,7 +5198,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5194
5198
}
5195
5199
5196
5200
// Ensure wrapping after __attribute__((XX)) and @interface etc.
5197
- if (Left.is (TT_AttributeParen ) && Right.is (TT_ObjCDecl))
5201
+ if (Left.is (TT_AttributeRParen ) && Right.is (TT_ObjCDecl))
5198
5202
return true ;
5199
5203
5200
5204
if (Left.is (TT_LambdaLBrace)) {
@@ -5556,8 +5560,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
5556
5560
!Style.Cpp11BracedListStyle ) {
5557
5561
return false ;
5558
5562
}
5559
- if (Left.is (tok::l_paren) &&
5560
- Left.isOneOf (TT_AttributeParen, TT_TypeDeclarationParen)) {
5563
+ if (Left.is (TT_AttributeLParen) ||
5564
+ ( Left.is (tok::l_paren) && Left. is ( TT_TypeDeclarationParen) )) {
5561
5565
return false ;
5562
5566
}
5563
5567
if (Left.is (tok::l_paren) && Left.Previous &&
0 commit comments