[PATCH] D158571: [clang-format][NFC] Replace !is() with isNot()

2023-08-24 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91c4db00612b: [clang-format][NFC] Replace !is() with isNot() 
(authored by owenpan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158571/new/

https://reviews.llvm.org/D158571

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenSource.h
  clang/lib/Format/MacroExpander.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp

Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -590,14 +590,14 @@
 
   // A new line starts, re-initialize line status tracking bools.
   // Keep the match state if a string literal is continued on this line.
-  if (i == 0 || !Changes[i].Tok->is(tok::string_literal) ||
-  !Changes[i - 1].Tok->is(tok::string_literal)) {
+  if (i == 0 || Changes[i].Tok->isNot(tok::string_literal) ||
+  Changes[i - 1].Tok->isNot(tok::string_literal)) {
 FoundMatchOnLine = false;
   }
   LineIsComment = true;
 }
 
-if (!Changes[i].Tok->is(tok::comment))
+if (Changes[i].Tok->isNot(tok::comment))
   LineIsComment = false;
 
 if (Changes[i].Tok->is(tok::comma)) {
@@ -731,10 +731,10 @@
   SpacesRequiredBefore = 0;
 }
 
-if (!Current || !Current->is(tok::identifier))
+if (!Current || Current->isNot(tok::identifier))
   return false;
 
-if (!Current->Previous || !Current->Previous->is(tok::pp_define))
+if (!Current->Previous || Current->Previous->isNot(tok::pp_define))
   return false;
 
 // For a macro function, 0 spaces are required between the
@@ -781,7 +781,7 @@
   LineIsComment = true;
 }
 
-if (!Changes[I].Tok->is(tok::comment))
+if (Changes[I].Tok->isNot(tok::comment))
   LineIsComment = false;
 
 if (!AlignMacrosMatches(Changes[I]))
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -394,7 +394,7 @@
 ParseDefault();
 continue;
   }
-  if (CanContainBracedList && !FormatTok->is(TT_MacroBlockBegin) &&
+  if (CanContainBracedList && FormatTok->isNot(TT_MacroBlockBegin) &&
   tryToParseBracedList()) {
 continue;
   }
@@ -615,7 +615,7 @@
   LBraceStack.pop_back();
   break;
 case tok::identifier:
-  if (!Tok->is(TT_StatementMacro))
+  if (Tok->isNot(TT_StatementMacro))
 break;
   [[fallthrough]];
 case tok::at:
@@ -799,8 +799,8 @@
   if (eof())
 return IfLBrace;
 
-  if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
- : !FormatTok->is(tok::r_brace)) {
+  if (MacroBlock ? FormatTok->isNot(TT_MacroBlockEnd)
+ : FormatTok->isNot(tok::r_brace)) {
 Line->Level = InitialLevel;
 FormatTok->setBlockKind(BK_Block);
 return IfLBrace;
@@ -1080,7 +1080,7 @@
   bool MaybeIncludeGuard = IfNDef;
   if (IncludeGuard == IG_Inited && MaybeIncludeGuard) {
 for (auto  : Lines) {
-  if (!Line.Tokens.front().Tok->is(tok::comment)) {
+  if (Line.Tokens.front().Tok->isNot(tok::comment)) {
 MaybeIncludeGuard = false;
 IncludeGuard = IG_Rejected;
 break;
@@ -1612,7 +1612,7 @@
 nextToken();
 if (FormatTok->is(tok::kw_public))
   nextToken();
-if (!FormatTok->is(tok::string_literal))
+if (FormatTok->isNot(tok::string_literal))
   return;
 nextToken();
 if (FormatTok->is(tok::semi))
@@ -1887,8 +1887,9 @@
   // a new unwrapped line, so they are special cased below.
   size_t TokenCount = Line->Tokens.size();
   if (Style.isJavaScript() && FormatTok->is(Keywords.kw_function) &&
-  (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is(
- Keywords.kw_async {
+  (TokenCount > 1 ||
+   (TokenCount == 1 &&
+Line->Tokens.front().Tok->isNot(Keywords.kw_async {
 tryToParseJSFunction();
 break;
   }
@@ -2872,7 +2873,7 @@
   FormatTok->is(tok::l_brace)) {
 do {
   nextToken();
-} while (!FormatTok->is(tok::r_brace));
+} while (FormatTok->isNot(tok::r_brace));
 nextToken();
   }
 
@@ -2895,7 +2896,7 @@
   

[PATCH] D158571: [clang-format][NFC] Replace !is() with isNot()

2023-08-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 553032.
owenpan added a comment.

Rebased to 825cec2 
 and ran 
`git-clang-format`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158571/new/

https://reviews.llvm.org/D158571

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenSource.h
  clang/lib/Format/MacroExpander.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp

Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -590,14 +590,14 @@
 
   // A new line starts, re-initialize line status tracking bools.
   // Keep the match state if a string literal is continued on this line.
-  if (i == 0 || !Changes[i].Tok->is(tok::string_literal) ||
-  !Changes[i - 1].Tok->is(tok::string_literal)) {
+  if (i == 0 || Changes[i].Tok->isNot(tok::string_literal) ||
+  Changes[i - 1].Tok->isNot(tok::string_literal)) {
 FoundMatchOnLine = false;
   }
   LineIsComment = true;
 }
 
-if (!Changes[i].Tok->is(tok::comment))
+if (Changes[i].Tok->isNot(tok::comment))
   LineIsComment = false;
 
 if (Changes[i].Tok->is(tok::comma)) {
@@ -731,10 +731,10 @@
   SpacesRequiredBefore = 0;
 }
 
-if (!Current || !Current->is(tok::identifier))
+if (!Current || Current->isNot(tok::identifier))
   return false;
 
-if (!Current->Previous || !Current->Previous->is(tok::pp_define))
+if (!Current->Previous || Current->Previous->isNot(tok::pp_define))
   return false;
 
 // For a macro function, 0 spaces are required between the
@@ -781,7 +781,7 @@
   LineIsComment = true;
 }
 
-if (!Changes[I].Tok->is(tok::comment))
+if (Changes[I].Tok->isNot(tok::comment))
   LineIsComment = false;
 
 if (!AlignMacrosMatches(Changes[I]))
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -394,7 +394,7 @@
 ParseDefault();
 continue;
   }
-  if (CanContainBracedList && !FormatTok->is(TT_MacroBlockBegin) &&
+  if (CanContainBracedList && FormatTok->isNot(TT_MacroBlockBegin) &&
   tryToParseBracedList()) {
 continue;
   }
@@ -615,7 +615,7 @@
   LBraceStack.pop_back();
   break;
 case tok::identifier:
-  if (!Tok->is(TT_StatementMacro))
+  if (Tok->isNot(TT_StatementMacro))
 break;
   [[fallthrough]];
 case tok::at:
@@ -799,8 +799,8 @@
   if (eof())
 return IfLBrace;
 
-  if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
- : !FormatTok->is(tok::r_brace)) {
+  if (MacroBlock ? FormatTok->isNot(TT_MacroBlockEnd)
+ : FormatTok->isNot(tok::r_brace)) {
 Line->Level = InitialLevel;
 FormatTok->setBlockKind(BK_Block);
 return IfLBrace;
@@ -1080,7 +1080,7 @@
   bool MaybeIncludeGuard = IfNDef;
   if (IncludeGuard == IG_Inited && MaybeIncludeGuard) {
 for (auto  : Lines) {
-  if (!Line.Tokens.front().Tok->is(tok::comment)) {
+  if (Line.Tokens.front().Tok->isNot(tok::comment)) {
 MaybeIncludeGuard = false;
 IncludeGuard = IG_Rejected;
 break;
@@ -1612,7 +1612,7 @@
 nextToken();
 if (FormatTok->is(tok::kw_public))
   nextToken();
-if (!FormatTok->is(tok::string_literal))
+if (FormatTok->isNot(tok::string_literal))
   return;
 nextToken();
 if (FormatTok->is(tok::semi))
@@ -1887,8 +1887,9 @@
   // a new unwrapped line, so they are special cased below.
   size_t TokenCount = Line->Tokens.size();
   if (Style.isJavaScript() && FormatTok->is(Keywords.kw_function) &&
-  (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is(
- Keywords.kw_async {
+  (TokenCount > 1 ||
+   (TokenCount == 1 &&
+Line->Tokens.front().Tok->isNot(Keywords.kw_async {
 tryToParseJSFunction();
 break;
   }
@@ -2872,7 +2873,7 @@
   FormatTok->is(tok::l_brace)) {
 do {
   nextToken();
-} while (!FormatTok->is(tok::r_brace));
+} while (FormatTok->isNot(tok::r_brace));
 nextToken();
   }
 
@@ -2895,7 +2896,7 @@
   addUnwrappedLine();
 else
   NeedsUnwrappedLine = true;
-  } else if 

[PATCH] D158571: [clang-format][NFC] Replace !is() with isNot()

2023-08-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
owenpan requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158571

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenSource.h
  clang/lib/Format/MacroExpander.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp

Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -590,14 +590,14 @@
 
   // A new line starts, re-initialize line status tracking bools.
   // Keep the match state if a string literal is continued on this line.
-  if (i == 0 || !Changes[i].Tok->is(tok::string_literal) ||
-  !Changes[i - 1].Tok->is(tok::string_literal)) {
+  if (i == 0 || Changes[i].Tok->isNot(tok::string_literal) ||
+  Changes[i - 1].Tok->isNot(tok::string_literal)) {
 FoundMatchOnLine = false;
   }
   LineIsComment = true;
 }
 
-if (!Changes[i].Tok->is(tok::comment))
+if (Changes[i].Tok->isNot(tok::comment))
   LineIsComment = false;
 
 if (Changes[i].Tok->is(tok::comma)) {
@@ -731,10 +731,10 @@
   SpacesRequiredBefore = 0;
 }
 
-if (!Current || !Current->is(tok::identifier))
+if (!Current || Current->isNot(tok::identifier))
   return false;
 
-if (!Current->Previous || !Current->Previous->is(tok::pp_define))
+if (!Current->Previous || Current->Previous->isNot(tok::pp_define))
   return false;
 
 // For a macro function, 0 spaces are required between the
@@ -781,7 +781,7 @@
   LineIsComment = true;
 }
 
-if (!Changes[I].Tok->is(tok::comment))
+if (Changes[I].Tok->isNot(tok::comment))
   LineIsComment = false;
 
 if (!AlignMacrosMatches(Changes[I]))
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -394,7 +394,7 @@
 ParseDefault();
 continue;
   }
-  if (CanContainBracedList && !FormatTok->is(TT_MacroBlockBegin) &&
+  if (CanContainBracedList && FormatTok->isNot(TT_MacroBlockBegin) &&
   tryToParseBracedList()) {
 continue;
   }
@@ -615,7 +615,7 @@
   LBraceStack.pop_back();
   break;
 case tok::identifier:
-  if (!Tok->is(TT_StatementMacro))
+  if (Tok->isNot(TT_StatementMacro))
 break;
   [[fallthrough]];
 case tok::at:
@@ -799,8 +799,8 @@
   if (eof())
 return IfLBrace;
 
-  if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
- : !FormatTok->is(tok::r_brace)) {
+  if (MacroBlock ? FormatTok->isNot(TT_MacroBlockEnd)
+ : FormatTok->isNot(tok::r_brace)) {
 Line->Level = InitialLevel;
 FormatTok->setBlockKind(BK_Block);
 return IfLBrace;
@@ -1080,7 +1080,7 @@
   bool MaybeIncludeGuard = IfNDef;
   if (IncludeGuard == IG_Inited && MaybeIncludeGuard) {
 for (auto  : Lines) {
-  if (!Line.Tokens.front().Tok->is(tok::comment)) {
+  if (Line.Tokens.front().Tok->isNot(tok::comment)) {
 MaybeIncludeGuard = false;
 IncludeGuard = IG_Rejected;
 break;
@@ -1612,7 +1612,7 @@
 nextToken();
 if (FormatTok->is(tok::kw_public))
   nextToken();
-if (!FormatTok->is(tok::string_literal))
+if (FormatTok->isNot(tok::string_literal))
   return;
 nextToken();
 if (FormatTok->is(tok::semi))
@@ -1887,7 +1887,7 @@
   // a new unwrapped line, so they are special cased below.
   size_t TokenCount = Line->Tokens.size();
   if (Style.isJavaScript() && FormatTok->is(Keywords.kw_function) &&
-  (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is(
+  (TokenCount > 1 || (TokenCount == 1 && Line->Tokens.front().Tok->isNot(
  Keywords.kw_async {
 tryToParseJSFunction();
 break;
@@ -2872,7 +2872,7 @@
   FormatTok->is(tok::l_brace)) {
 do {
   nextToken();
-} while (!FormatTok->is(tok::r_brace));
+} while (FormatTok->isNot(tok::r_brace));
 nextToken();
   }
 
@@ -2895,7 +2895,7 @@
   addUnwrappedLine();
 else
   NeedsUnwrappedLine = true;
-  } else if (!FormatTok->is(tok::kw_catch)) {
+  } else if