Skip to content

Commit 684f27d

Browse files
committed
[clang-format][NFC] Use is instead of getType() ==
1 parent 09efe84 commit 684f27d

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ bool FormatTokenLexer::tryMergeNullishCoalescingEqual() {
404404
return false;
405405
auto &NullishCoalescing = *(Tokens.end() - 2);
406406
auto &Equal = *(Tokens.end() - 1);
407-
if (NullishCoalescing->getType() != TT_NullCoalescingOperator ||
407+
if (NullishCoalescing->isNot(TT_NullCoalescingOperator) ||
408408
Equal->isNot(tok::equal)) {
409409
return false;
410410
}

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,7 @@ class AnnotatingParser {
825825
Parent->overwriteFixedType(TT_BinaryOperator);
826826
}
827827
// An arrow after an ObjC method expression is not a lambda arrow.
828-
if (CurrentToken->getType() == TT_ObjCMethodExpr &&
829-
CurrentToken->Next &&
828+
if (CurrentToken->is(TT_ObjCMethodExpr) && CurrentToken->Next &&
830829
CurrentToken->Next->is(TT_TrailingReturnArrow)) {
831830
CurrentToken->Next->overwriteFixedType(TT_Unknown);
832831
}
@@ -1563,7 +1562,7 @@ class AnnotatingParser {
15631562
case tok::l_brace:
15641563
if (Style.Language == FormatStyle::LK_TextProto) {
15651564
FormatToken *Previous = Tok->getPreviousNonComment();
1566-
if (Previous && Previous->getType() != TT_DictLiteral)
1565+
if (Previous && Previous->isNot(TT_DictLiteral))
15671566
Previous->setType(TT_SelectorName);
15681567
}
15691568
Scopes.push_back(getScopeType(*Tok));
@@ -1583,7 +1582,7 @@ class AnnotatingParser {
15831582
Tok->Previous->isOneOf(TT_SelectorName, TT_DictLiteral))) {
15841583
Tok->setType(TT_DictLiteral);
15851584
FormatToken *Previous = Tok->getPreviousNonComment();
1586-
if (Previous && Previous->getType() != TT_DictLiteral)
1585+
if (Previous && Previous->isNot(TT_DictLiteral))
15871586
Previous->setType(TT_SelectorName);
15881587
}
15891588
if (Style.isTableGen())
@@ -4754,8 +4753,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
47544753
// Objective-C dictionary literal -> no space before closing brace.
47554754
return false;
47564755
}
4757-
if (Right.getType() == TT_TrailingAnnotation &&
4758-
Right.isOneOf(tok::amp, tok::ampamp) &&
4756+
if (Right.is(TT_TrailingAnnotation) && Right.isOneOf(tok::amp, tok::ampamp) &&
47594757
Left.isOneOf(tok::kw_const, tok::kw_volatile) &&
47604758
(!Right.Next || Right.Next->is(tok::semi))) {
47614759
// Match const and volatile ref-qualifiers without any additional

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ bool UnwrappedLineParser::parseLevel(const FormatToken *OpeningBrace,
366366
continue;
367367
}
368368
tok::TokenKind Kind = FormatTok->Tok.getKind();
369-
if (FormatTok->getType() == TT_MacroBlockBegin)
369+
if (FormatTok->is(TT_MacroBlockBegin))
370370
Kind = tok::l_brace;
371-
else if (FormatTok->getType() == TT_MacroBlockEnd)
371+
else if (FormatTok->is(TT_MacroBlockEnd))
372372
Kind = tok::r_brace;
373373

374374
auto ParseDefault = [this, OpeningBrace, IfKind, &IfLBrace, &HasDoWhile,
@@ -4709,14 +4709,13 @@ void UnwrappedLineParser::readToken(int LevelDifference) {
47094709
do {
47104710
FormatTok = Tokens->getNextToken();
47114711
assert(FormatTok);
4712-
while (FormatTok->getType() == TT_ConflictStart ||
4713-
FormatTok->getType() == TT_ConflictEnd ||
4714-
FormatTok->getType() == TT_ConflictAlternative) {
4715-
if (FormatTok->getType() == TT_ConflictStart)
4712+
while (FormatTok->isOneOf(TT_ConflictStart, TT_ConflictEnd,
4713+
TT_ConflictAlternative)) {
4714+
if (FormatTok->is(TT_ConflictStart))
47164715
conditionalCompilationStart(/*Unreachable=*/false);
4717-
else if (FormatTok->getType() == TT_ConflictAlternative)
4716+
else if (FormatTok->is(TT_ConflictAlternative))
47184717
conditionalCompilationAlternative();
4719-
else if (FormatTok->getType() == TT_ConflictEnd)
4718+
else if (FormatTok->is(TT_ConflictEnd))
47204719
conditionalCompilationEnd();
47214720
FormatTok = Tokens->getNextToken();
47224721
FormatTok->MustBreakBefore = true;

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
473473
Style.ReferenceAlignment != FormatStyle::RAS_Right &&
474474
Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
475475
for (int Previous = i - 1;
476-
Previous >= 0 &&
477-
Changes[Previous].Tok->getType() == TT_PointerOrReference;
476+
Previous >= 0 && Changes[Previous].Tok->is(TT_PointerOrReference);
478477
--Previous) {
479478
assert(Changes[Previous].Tok->isPointerOrReference());
480479
if (Changes[Previous].Tok->isNot(tok::star)) {

0 commit comments

Comments
 (0)