@@ -1939,7 +1939,7 @@ class AnnotatingParser {
1939
1939
Contexts.back ().IsExpression = true ;
1940
1940
next ();
1941
1941
if (CurrentToken)
1942
- CurrentToken->SpacesRequiredBefore = true ;
1942
+ CurrentToken->SpacesRequiredBefore = 1 ;
1943
1943
parseLine ();
1944
1944
break ;
1945
1945
default :
@@ -2639,8 +2639,8 @@ class AnnotatingParser {
2639
2639
if (PreviousNotConst->is (TT_TemplateCloser)) {
2640
2640
return PreviousNotConst && PreviousNotConst->MatchingParen &&
2641
2641
PreviousNotConst->MatchingParen ->Previous &&
2642
- PreviousNotConst->MatchingParen ->Previous ->isNot (tok::period) &&
2643
- PreviousNotConst-> MatchingParen -> Previous -> isNot ( tok::kw_template);
2642
+ ! PreviousNotConst->MatchingParen ->Previous ->isOneOf (
2643
+ tok::period, tok::kw_template);
2644
2644
}
2645
2645
2646
2646
if ((PreviousNotConst->is (tok::r_paren) &&
@@ -3369,7 +3369,7 @@ class ExpressionParser {
3369
3369
Current->isOneOf (Keywords.kw_in , Keywords.kw_as )) {
3370
3370
return prec::Relational;
3371
3371
}
3372
- if (Current->is (TT_BinaryOperator) || Current-> is ( tok::comma))
3372
+ if (Current->isOneOf (TT_BinaryOperator, tok::comma))
3373
3373
return Current->getPrecedence ();
3374
3374
if (Current->isOneOf (tok::period, tok::arrow) &&
3375
3375
Current->isNot (TT_TrailingReturnArrow)) {
@@ -4314,8 +4314,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
4314
4314
4315
4315
if (Left.is (tok::coloncolon))
4316
4316
return Style.PenaltyBreakScopeResolution ;
4317
- if (Right.isOneOf (TT_StartOfName, TT_FunctionDeclarationName) ||
4318
- Right. is ( tok::kw_operator)) {
4317
+ if (Right.isOneOf (TT_StartOfName, TT_FunctionDeclarationName,
4318
+ tok::kw_operator)) {
4319
4319
if (Line.startsWith (tok::kw_for) && Right.PartOfMultiVariableDeclStmt )
4320
4320
return 3 ;
4321
4321
if (Left.is (TT_StartOfName))
@@ -4757,7 +4757,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4757
4757
if (Previous) {
4758
4758
if (Previous->endsSequence (tok::kw_operator))
4759
4759
return Style.PointerAlignment != FormatStyle::PAS_Left;
4760
- if (Previous->is (tok::kw_const) || Previous-> is ( tok::kw_volatile)) {
4760
+ if (Previous->isOneOf (tok::kw_const, tok::kw_volatile)) {
4761
4761
return (Style.PointerAlignment != FormatStyle::PAS_Left) ||
4762
4762
(Style.SpaceAroundPointerQualifiers ==
4763
4763
FormatStyle::SAPQ_After) ||
@@ -4931,8 +4931,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4931
4931
}
4932
4932
if (Left.is (TT_TemplateCloser) && Left.MatchingParen &&
4933
4933
Left.MatchingParen ->Previous &&
4934
- (Left.MatchingParen ->Previous ->is (tok::period) ||
4935
- Left.MatchingParen ->Previous ->is (tok::coloncolon))) {
4934
+ Left.MatchingParen ->Previous ->isOneOf (tok::period, tok::coloncolon)) {
4936
4935
// Java call to generic function with explicit type:
4937
4936
// A.<B<C<...>>>DoSomething();
4938
4937
// A::<B<C<...>>>DoSomething(); // With a Java 8 method reference.
@@ -5207,8 +5206,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
5207
5206
// (e.g. as "const x of y" in a for loop), or after a destructuring
5208
5207
// operation (const [x, y] of z, const {a, b} of c).
5209
5208
(Left.is (Keywords.kw_of ) && BeforeLeft &&
5210
- (BeforeLeft->is (tok::identifier) ||
5211
- BeforeLeft->isOneOf (tok::r_square, tok::r_brace)))) &&
5209
+ BeforeLeft->isOneOf (tok::identifier, tok::r_square, tok::r_brace))) &&
5212
5210
(!BeforeLeft || BeforeLeft->isNot (tok::period))) {
5213
5211
return true ;
5214
5212
}
@@ -5516,7 +5514,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
5516
5514
return false ;
5517
5515
}
5518
5516
if (Style.isJava () && Right.is (tok::coloncolon) &&
5519
- ( Left.is (tok::identifier) || Left. is ( tok::kw_this) )) {
5517
+ Left.isOneOf (tok::identifier, tok::kw_this)) {
5520
5518
return false ;
5521
5519
}
5522
5520
if (Right.is (tok::coloncolon) && Left.is (tok::identifier)) {
@@ -5587,8 +5585,8 @@ static bool IsFunctionArgument(const FormatToken &Tok) {
5587
5585
}
5588
5586
5589
5587
static bool
5590
- isItAnEmptyLambdaAllowed (const FormatToken &Tok,
5591
- FormatStyle::ShortLambdaStyle ShortLambdaOption) {
5588
+ isEmptyLambdaAllowed (const FormatToken &Tok,
5589
+ FormatStyle::ShortLambdaStyle ShortLambdaOption) {
5592
5590
return Tok.Children .empty () && ShortLambdaOption != FormatStyle::SLS_None;
5593
5591
}
5594
5592
@@ -5808,8 +5806,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5808
5806
}
5809
5807
5810
5808
if (Right.is (tok::comment)) {
5811
- return Left.isNot (BK_BracedInit) && Left. isNot ( TT_CtorInitializerColon) &&
5812
- ( Right.NewlinesBefore > 0 && Right.HasUnescapedNewline ) ;
5809
+ return ! Left.isOneOf (BK_BracedInit, TT_CtorInitializerColon) &&
5810
+ Right.NewlinesBefore > 0 && Right.HasUnescapedNewline ;
5813
5811
}
5814
5812
if (Left.isTrailingComment ())
5815
5813
return true ;
@@ -5977,7 +5975,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5977
5975
// Put multiple Java annotation on a new line.
5978
5976
if ((Style.isJava () || Style.isJavaScript ()) &&
5979
5977
Left.is (TT_LeadingJavaAnnotation) &&
5980
- Right.isNot (TT_LeadingJavaAnnotation) && Right. isNot ( tok::l_paren) &&
5978
+ ! Right.isOneOf (TT_LeadingJavaAnnotation, tok::l_paren) &&
5981
5979
(Line.Last ->is (tok::l_brace) || Style.BreakAfterJavaFieldAnnotations )) {
5982
5980
return true ;
5983
5981
}
@@ -6043,7 +6041,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
6043
6041
((LBrace->is (tok::l_brace) &&
6044
6042
(LBrace->is (TT_DictLiteral) ||
6045
6043
(LBrace->Next && LBrace->Next ->is (tok::r_brace)))) ||
6046
- LBrace->is (TT_ArrayInitializerLSquare) || LBrace-> is ( tok::less))) {
6044
+ LBrace->isOneOf (TT_ArrayInitializerLSquare, tok::less))) {
6047
6045
// If Left.ParameterCount is 0, then this submessage entry is not the
6048
6046
// first in its parent submessage, and we want to break before this entry.
6049
6047
// If Left.ParameterCount is greater than 0, then its parent submessage
@@ -6257,9 +6255,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6257
6255
}
6258
6256
if (Left.is (tok::question) && Right.is (tok::colon))
6259
6257
return false ;
6260
- if (Right.is (TT_ConditionalExpr) || Right. is ( tok::question))
6258
+ if (Right.isOneOf (TT_ConditionalExpr, tok::question))
6261
6259
return Style.BreakBeforeTernaryOperators ;
6262
- if (Left.is (TT_ConditionalExpr) || Left. is ( tok::question))
6260
+ if (Left.isOneOf (TT_ConditionalExpr, tok::question))
6263
6261
return !Style.BreakBeforeTernaryOperators ;
6264
6262
if (Left.is (TT_InheritanceColon))
6265
6263
return Style.BreakInheritanceList == FormatStyle::BILS_AfterColon;
@@ -6302,7 +6300,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6302
6300
// submessage: { ... }
6303
6301
// submessage: < ... >
6304
6302
// repeated: [ ... ]
6305
- if ((( Right.is (tok::l_brace) || Right. is ( tok::less) ) &&
6303
+ if ((Right.isOneOf (tok::l_brace, tok::less) &&
6306
6304
Right.is (TT_DictLiteral)) ||
6307
6305
Right.is (TT_ArrayInitializerLSquare)) {
6308
6306
return false ;
@@ -6352,10 +6350,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6352
6350
Right.getPrecedence () != prec::Assignment)) {
6353
6351
return true ;
6354
6352
}
6355
- if (Left.isOneOf (TT_TemplateCloser, TT_UnaryOperator) ||
6356
- Left.is (tok::kw_operator)) {
6353
+ if (Left.isOneOf (TT_TemplateCloser, TT_UnaryOperator, tok::kw_operator))
6357
6354
return false ;
6358
- }
6359
6355
if (Left.is (tok::equal) && !Right.isOneOf (tok::kw_default, tok::kw_delete) &&
6360
6356
Line.Type == LT_VirtualFunctionDecl && Left.NestingLevel == 0 ) {
6361
6357
return false ;
@@ -6440,9 +6436,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6440
6436
auto ShortLambdaOption = Style.AllowShortLambdasOnASingleLine ;
6441
6437
if (Style.BraceWrapping .BeforeLambdaBody && Right.is (TT_LambdaLBrace)) {
6442
6438
if (isAllmanLambdaBrace (Left))
6443
- return !isItAnEmptyLambdaAllowed (Left, ShortLambdaOption);
6439
+ return !isEmptyLambdaAllowed (Left, ShortLambdaOption);
6444
6440
if (isAllmanLambdaBrace (Right))
6445
- return !isItAnEmptyLambdaAllowed (Right, ShortLambdaOption);
6441
+ return !isEmptyLambdaAllowed (Right, ShortLambdaOption);
6446
6442
}
6447
6443
6448
6444
if (Right.is (tok::kw_noexcept) && Right.is (TT_TrailingAnnotation)) {
0 commit comments