@@ -405,7 +405,7 @@ class AnnotatingParser {
405
405
// void (^ObjCBlock)(void);
406
406
bool MightBeFunctionType = !Contexts[Contexts.size () - 2 ].IsExpression ;
407
407
bool ProbablyFunctionType =
408
- CurrentToken->isOneOf (tok::star, tok::amp, tok::ampamp, tok::caret);
408
+ CurrentToken->isPointerOrReference () || CurrentToken-> is ( tok::caret);
409
409
bool HasMultipleLines = false ;
410
410
bool HasMultipleParametersOnALine = false ;
411
411
bool MightBeObjCForRangeLoop =
@@ -422,8 +422,7 @@ class AnnotatingParser {
422
422
FormatToken *PrevPrev = Prev->getPreviousNonComment ();
423
423
FormatToken *Next = CurrentToken->Next ;
424
424
if (PrevPrev && PrevPrev->is (tok::identifier) &&
425
- PrevPrev->isNot (TT_TypeName) &&
426
- Prev->isOneOf (tok::star, tok::amp, tok::ampamp) &&
425
+ PrevPrev->isNot (TT_TypeName) && Prev->isPointerOrReference () &&
427
426
CurrentToken->is (tok::identifier) && Next->isNot (tok::equal)) {
428
427
Prev->setType (TT_BinaryOperator);
429
428
LookForDecls = false ;
@@ -460,10 +459,8 @@ class AnnotatingParser {
460
459
// auto my_lambda = MACRO((Type *type, int i) { .. body .. });
461
460
for (FormatToken *Tok = &OpeningParen; Tok != CurrentToken;
462
461
Tok = Tok->Next ) {
463
- if (Tok->is (TT_BinaryOperator) &&
464
- Tok->isOneOf (tok::star, tok::amp, tok::ampamp)) {
462
+ if (Tok->is (TT_BinaryOperator) && Tok->isPointerOrReference ())
465
463
Tok->setType (TT_PointerOrReference);
466
- }
467
464
}
468
465
}
469
466
@@ -1861,8 +1858,8 @@ class AnnotatingParser {
1861
1858
if (Previous->opensScope ())
1862
1859
break ;
1863
1860
if (Previous->isOneOf (TT_BinaryOperator, TT_UnaryOperator) &&
1864
- Previous->isOneOf (tok::star, tok::amp, tok::ampamp) &&
1865
- Previous->Previous && Previous-> Previous ->isNot (tok::equal)) {
1861
+ Previous->isPointerOrReference () && Previous-> Previous &&
1862
+ Previous->Previous ->isNot (tok::equal)) {
1866
1863
Previous->setType (TT_PointerOrReference);
1867
1864
}
1868
1865
}
@@ -2023,7 +2020,7 @@ class AnnotatingParser {
2023
2020
} else if (isDeductionGuide (Current)) {
2024
2021
// Deduction guides trailing arrow " A(...) -> A<T>;".
2025
2022
Current.setType (TT_TrailingReturnArrow);
2026
- } else if (Current.isOneOf (tok::star, tok::amp, tok::ampamp )) {
2023
+ } else if (Current.isPointerOrReference ( )) {
2027
2024
Current.setType (determineStarAmpUsage (
2028
2025
Current,
2029
2026
Contexts.back ().CanBeExpression && Contexts.back ().IsExpression ,
@@ -3281,7 +3278,7 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
3281
3278
continue ;
3282
3279
}
3283
3280
if ((Next->isSimpleTypeSpecifier () || Next->is (tok::identifier)) &&
3284
- Next->Next && Next->Next ->isOneOf (tok::star, tok::amp, tok::ampamp )) {
3281
+ Next->Next && Next->Next ->isPointerOrReference ( )) {
3285
3282
// For operator void*(), operator char*(), operator Foo*().
3286
3283
Next = Next->Next ;
3287
3284
continue ;
@@ -3310,7 +3307,7 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
3310
3307
assert (Previous->MatchingParen ->is (TT_TypeDeclarationParen));
3311
3308
return true ;
3312
3309
}
3313
- if (!Previous->isOneOf (tok::star, tok::amp, tok::ampamp, TT_TemplateCloser))
3310
+ if (!Previous->isPointerOrReference () && Previous-> isNot ( TT_TemplateCloser))
3314
3311
return false ;
3315
3312
Next = skipOperatorName (Next);
3316
3313
} else {
@@ -3481,8 +3478,8 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
3481
3478
continue ;
3482
3479
auto *Next = Tok->Next ;
3483
3480
const bool NextIsBinaryOperator =
3484
- Next && Next->isOneOf (tok::star, tok::amp, tok::ampamp) &&
3485
- Next->Next && Next-> Next ->is (tok::identifier);
3481
+ Next && Next->isPointerOrReference () && Next-> Next &&
3482
+ Next->Next ->is (tok::identifier);
3486
3483
if (!NextIsBinaryOperator)
3487
3484
continue ;
3488
3485
Next->setType (TT_BinaryOperator);
@@ -4105,15 +4102,15 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4105
4102
}
4106
4103
// Ensure right pointer alignment with ellipsis e.g. int *...P
4107
4104
if (Left.is (tok::ellipsis) && Left.Previous &&
4108
- Left.Previous ->isOneOf (tok::star, tok::amp, tok::ampamp )) {
4105
+ Left.Previous ->isPointerOrReference ( )) {
4109
4106
return Style.PointerAlignment != FormatStyle::PAS_Right;
4110
4107
}
4111
4108
4112
4109
if (Right.is (tok::star) && Left.is (tok::l_paren))
4113
4110
return false ;
4114
- if (Left.is (tok::star) && Right.isOneOf (tok::star, tok::amp, tok::ampamp ))
4111
+ if (Left.is (tok::star) && Right.isPointerOrReference ( ))
4115
4112
return false ;
4116
- if (Right.isOneOf (tok::star, tok::amp, tok::ampamp )) {
4113
+ if (Right.isPointerOrReference ( )) {
4117
4114
const FormatToken *Previous = &Left;
4118
4115
while (Previous && Previous->isNot (tok::kw_operator)) {
4119
4116
if (Previous->is (tok::identifier) || Previous->isSimpleTypeSpecifier ()) {
@@ -5258,7 +5255,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5258
5255
}
5259
5256
5260
5257
if (Style.BraceWrapping .BeforeLambdaBody && Right.is (TT_LambdaLBrace) &&
5261
- Left.isOneOf (tok::star, tok::amp, tok::ampamp, TT_TemplateCloser)) {
5258
+ ( Left.isPointerOrReference () || Left. is ( TT_TemplateCloser) )) {
5262
5259
return true ;
5263
5260
}
5264
5261
0 commit comments