hkmatsumoto created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
hkmatsumoto requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Given that isa<Foo, Bar>(A) is equivalent to isa<Foo>(A) || isa<Bar>(A),
we can refactor the codebase as follows:

- Change isa<Foo>(A) || isa<Bar>(A) to isa<Foo, Bar>(A)
- Change !isa<Foo>(A) && !isa<Bar>(A) to !isa<Foo, Bar>(A)

Fixes https://github.com/llvm/llvm-project/issues/45827
Related to https://reviews.llvm.org/D122416


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122417

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===================================================================
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -929,7 +929,7 @@
                                           SourceLocation Loc,
                                           CXTranslationUnit TU) {
 
-  assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU &&
+  assert(NS && (isa<NamespaceDecl, NamespaceAliasDecl>(NS)) && TU &&
          "Invalid arguments!");
   void *RawLoc = Loc.getPtrEncoding();
   CXCursor C = {CXCursor_NamespaceRef, 0, {NS, RawLoc, TU}};
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -441,7 +441,7 @@
   }
 
   // For most kinds of declaration, it doesn't really matter which one we pick.
-  if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
+  if (!isa<FunctionDecl, VarDecl>(DUnderlying)) {
     // If the existing declaration is hidden, prefer the new one. Otherwise,
     // keep what we've got.
     return !S.isVisible(Existing);
Index: clang/lib/CodeGen/CGExprScalar.cpp
===================================================================
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -173,7 +173,7 @@
 
 /// Check if we can skip the overflow check for \p Op.
 static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) {
-  assert((isa<UnaryOperator>(Op.E) || isa<BinaryOperator>(Op.E)) &&
+  assert((isa<UnaryOperator, BinaryOperator>(Op.E)) &&
          "Expected a unary or binary operator");
 
   // If the binop has constant inputs and we can prove there is no overflow,
Index: clang/lib/CodeGen/CGDecl.cpp
===================================================================
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -298,7 +298,7 @@
 
   // We can't name blocks or captured statements directly, so try to emit their
   // parents.
-  if (isa<BlockDecl>(DC) || isa<CapturedDecl>(DC)) {
+  if (isa<BlockDecl, CapturedDecl>(DC)) {
     DC = DC->getNonClosureContext();
     // FIXME: Ensure that global blocks get emitted.
     if (!DC)
Index: clang/lib/AST/TypeLoc.cpp
===================================================================
--- clang/lib/AST/TypeLoc.cpp
+++ clang/lib/AST/TypeLoc.cpp
@@ -438,8 +438,7 @@
 SourceLocation TypeLoc::findNullabilityLoc() const {
   if (auto ATL = getAs<AttributedTypeLoc>()) {
     const Attr *A = ATL.getAttr();
-    if (A && (isa<TypeNullableAttr>(A) || isa<TypeNonNullAttr>(A) ||
-              isa<TypeNullUnspecifiedAttr>(A)))
+    if (A && isa<TypeNullableAttr, TypeNonNullAttr, TypeNullUnspecifiedAttr>(A))
       return A->getLocation();
   }
 
Index: clang/lib/AST/StmtOpenMP.cpp
===================================================================
--- clang/lib/AST/StmtOpenMP.cpp
+++ clang/lib/AST/StmtOpenMP.cpp
@@ -94,7 +94,7 @@
             continue;
           if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(S))
             S = CanonLoop->getLoopStmt();
-          if (isa<ForStmt>(S) || isa<CXXForRangeStmt>(S) ||
+          if (isa<ForStmt, CXXForRangeStmt>(S) ||
               (isa<OMPLoopBasedDirective>(S) && !isa<OMPLoopDirective>(S))) {
             // Only single loop construct is allowed.
             if (CurStmt) {
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -292,7 +292,7 @@
     void write(raw_ostream &Out, const NamedDecl *ND,
                const AbiTagList *AdditionalAbiTags) {
       ND = cast<NamedDecl>(ND->getCanonicalDecl());
-      if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
+      if (!isa<FunctionDecl, VarDecl>(ND)) {
         assert(
             !AdditionalAbiTags &&
             "only function and variables need a list of additional abi tags");
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -303,7 +303,7 @@
   const Decl *Ret = nullptr;
   const DeclContext *DC = D->getDeclContext();
   while (DC->getDeclKind() != Decl::TranslationUnit) {
-    if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
+    if (isa<FunctionDecl, BlockDecl>(DC))
       Ret = cast<Decl>(DC);
     DC = DC->getParent();
   }
Index: clang-tools-extra/clangd/InlayHints.cpp
===================================================================
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -236,7 +236,7 @@
     // syntax or user-defined literals. (Among other reasons, the resulting
     // hints can look awkard, e.g. the expression can itself be a function
     // argument and then we'd get two hints side by side).
-    if (isa<CXXOperatorCallExpr>(E) || isa<UserDefinedLiteral>(E))
+    if (isa<CxxOperatorCallExpr, UserDefinedLiteral>(E))
       return true;
 
     auto CalleeDecls = Resolver->resolveCalleeOfCallExpr(E);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D122417: [Clan... Hirochika Matsumoto via Phabricator via cfe-commits

Reply via email to