summaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineFormatter.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2023-08-24 01:13:05 -0700
committerOwen Pan <owenpiano@gmail.com>2023-08-24 01:27:24 -0700
commit91c4db00612b205c6d0f56990b657c5646ad2a3b (patch)
tree3280398fb113f169f43ae936fac9f875c15bcab9 /clang/lib/Format/UnwrappedLineFormatter.cpp
parent185bf56079255c7277686d2cd944664fe41e3bbb (diff)
[clang-format][NFC] Replace !is() with isNot()
Differential Revision: https://reviews.llvm.org/D158571
Diffstat (limited to 'clang/lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineFormatter.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 52519145279c..8f0b05ecb91d 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -405,7 +405,8 @@ private:
openingLine == I[i + 1]->MatchingOpeningBlockLineIndex;
i++, --openingLine) {
// No space between consecutive braces.
- I[i + 1]->First->SpacesRequiredBefore = !I[i]->Last->is(tok::r_brace);
+ I[i + 1]->First->SpacesRequiredBefore =
+ I[i]->Last->isNot(tok::r_brace);
// Indent like the outer-most namespace.
IndentTracker.nextLine(*I[i + 1]);
@@ -622,12 +623,12 @@ private:
}
Limit = limitConsideringMacros(I + 1, E, Limit);
AnnotatedLine &Line = **I;
- if (!Line.First->is(tok::kw_do) && !Line.First->is(tok::kw_else) &&
- !Line.Last->is(tok::kw_else) && Line.Last->isNot(tok::r_paren)) {
+ if (Line.First->isNot(tok::kw_do) && Line.First->isNot(tok::kw_else) &&
+ Line.Last->isNot(tok::kw_else) && Line.Last->isNot(tok::r_paren)) {
return 0;
}
// Only merge `do while` if `do` is the only statement on the line.
- if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
+ if (Line.First->is(tok::kw_do) && Line.Last->isNot(tok::kw_do))
return 0;
if (1 + I[1]->Last->TotalLength > Limit)
return 0;
@@ -754,21 +755,21 @@ private:
if (!Style.AllowShortIfStatementsOnASingleLine &&
Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
!Style.BraceWrapping.AfterControlStatement &&
- !I[1]->First->is(tok::r_brace)) {
+ I[1]->First->isNot(tok::r_brace)) {
return 0;
}
if (!Style.AllowShortIfStatementsOnASingleLine &&
Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
Style.BraceWrapping.AfterControlStatement ==
FormatStyle::BWACS_Always &&
- I + 2 != E && !I[2]->First->is(tok::r_brace)) {
+ I + 2 != E && I[2]->First->isNot(tok::r_brace)) {
return 0;
}
if (!Style.AllowShortLoopsOnASingleLine &&
Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
TT_ForEachMacro) &&
!Style.BraceWrapping.AfterControlStatement &&
- !I[1]->First->is(tok::r_brace)) {
+ I[1]->First->isNot(tok::r_brace)) {
return 0;
}
if (!Style.AllowShortLoopsOnASingleLine &&
@@ -776,7 +777,7 @@ private:
TT_ForEachMacro) &&
Style.BraceWrapping.AfterControlStatement ==
FormatStyle::BWACS_Always &&
- I + 2 != E && !I[2]->First->is(tok::r_brace)) {
+ I + 2 != E && I[2]->First->isNot(tok::r_brace)) {
return 0;
}
// FIXME: Consider an option to allow short exception handling clauses on
@@ -886,7 +887,7 @@ private:
SmallVectorImpl<AnnotatedLine *>::const_iterator E,
unsigned Limit) {
if (I[0]->InPPDirective && I + 1 != E &&
- !I[1]->First->HasUnescapedNewline && !I[1]->First->is(tok::eof)) {
+ !I[1]->First->HasUnescapedNewline && I[1]->First->isNot(tok::eof)) {
return Limit < 2 ? 0 : Limit - 2;
}
return Limit;
@@ -1494,8 +1495,10 @@ static auto computeNewlines(const AnnotatedLine &Line,
previousToken = PreviousLine->Last->getPreviousNonComment();
else
previousToken = PreviousLine->Last;
- if ((!previousToken || !previousToken->is(tok::l_brace)) && Newlines <= 1)
+ if ((!previousToken || previousToken->isNot(tok::l_brace)) &&
+ Newlines <= 1) {
Newlines = 2;
+ }
} break;
}
}