Author: Kazu Hirata Date: 2021-12-24T21:22:27-08:00 New Revision: 62e48ed10f9d2328331378f7c070487e58346a7e
URL: https://github.com/llvm/llvm-project/commit/62e48ed10f9d2328331378f7c070487e58346a7e DIFF: https://github.com/llvm/llvm-project/commit/62e48ed10f9d2328331378f7c070487e58346a7e.diff LOG: Use isa instead of dyn_cast (NFC) Added: Modified: clang-tools-extra/clang-doc/Mapper.cpp clang-tools-extra/clang-doc/Serialize.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h clang/lib/Sema/SemaExprCXX.cpp lld/COFF/Driver.cpp lld/ELF/Symbols.cpp lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index 790f11bb69c5b..de7e4c3410866 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -68,7 +68,7 @@ bool MapASTVisitor::VisitCXXMethodDecl(const CXXMethodDecl *D) { bool MapASTVisitor::VisitFunctionDecl(const FunctionDecl *D) { // Don't visit CXXMethodDecls twice - if (dyn_cast<CXXMethodDecl>(D)) + if (isa<CXXMethodDecl>(D)) return true; return mapDecl(D); } diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index e132c56cb0001..29762b6b54b1e 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -382,7 +382,7 @@ populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces, // corresponds to a Record and if it doesn't have any namespace (because this // means it's in the global namespace). Also if its outermost namespace is a // record because that record matches the previous condition mentioned. - if ((Namespaces.empty() && dyn_cast<RecordDecl>(D)) || + if ((Namespaces.empty() && isa<RecordDecl>(D)) || (!Namespaces.empty() && Namespaces.back().RefType == InfoType::IT_record)) Namespaces.emplace_back(SymbolID(), "GlobalNamespace", InfoType::IT_namespace); @@ -419,10 +419,10 @@ static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D, populateSymbolInfo(I, D, FC, LineNumber, Filename, IsFileInRootDir, IsInAnonymousNamespace); if (const auto *T = getDeclForType(D->getReturnType())) { - if (dyn_cast<EnumDecl>(T)) + if (isa<EnumDecl>(T)) I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(), InfoType::IT_enum, getInfoRelativePath(T)); - else if (dyn_cast<RecordDecl>(T)) + else if (isa<RecordDecl>(T)) I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(), InfoType::IT_record, getInfoRelativePath(T)); } else { diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index 432d929057d14..b0b882be1a6c7 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -829,7 +829,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context, } else if (FixerKind == LFK_PseudoArray) { // This call is required to obtain the container. const auto *EndCall = Nodes.getNodeAs<CXXMemberCallExpr>(EndCallName); - if (!EndCall || !dyn_cast<MemberExpr>(EndCall->getCallee())) + if (!EndCall || !isa<MemberExpr>(EndCall->getCallee())) return false; } return true; diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index 4a58fe8709442..a0ae44131b45a 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -155,7 +155,7 @@ class CFGWalker { return false; // Ignore anonymous functions. - if (!dyn_cast_or_null<NamedDecl>(AC.getDecl())) + if (!isa_and_nonnull<NamedDecl>(AC.getDecl())) return false; SortedGraph = AC.getAnalysis<PostOrderCFGView>(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index d25f329f85e45..54f0242d2ca12 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1346,7 +1346,7 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, const bool Explicit, // implicitly capturing the *enclosing object* by reference (see loop // above)). assert((!ByCopy || - dyn_cast<LambdaScopeInfo>(FunctionScopes[MaxFunctionScopesIndex])) && + isa<LambdaScopeInfo>(FunctionScopes[MaxFunctionScopesIndex])) && "Only a lambda can capture the enclosing object (referred to by " "*this) by copy"); QualType ThisTy = getCurrentThisType(); diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index f1b0c5c0707d1..07b60673577e2 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -2085,7 +2085,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { if (args.hasArg(OPT_include_optional)) { // Handle /includeoptional for (auto *arg : args.filtered(OPT_include_optional)) - if (dyn_cast_or_null<LazyArchive>(ctx.symtab.find(arg->getValue()))) + if (isa_and_nonnull<LazyArchive>(ctx.symtab.find(arg->getValue()))) addUndefined(arg->getValue()); while (run()); } diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 23f8d3ef545ee..20301497a059e 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -550,7 +550,7 @@ void Symbol::resolveUndefined(const Undefined &other) { } // Undefined symbols in a SharedFile do not change the binding. - if (dyn_cast_or_null<SharedFile>(other.file)) + if (isa_and_nonnull<SharedFile>(other.file)) return; if (isUndefined() || isShared()) { @@ -608,7 +608,7 @@ int Symbol::compare(const Symbol *other) const { auto *oldSym = cast<Defined>(this); auto *newSym = cast<Defined>(other); - if (dyn_cast_or_null<BitcodeFile>(other->file)) + if (isa_and_nonnull<BitcodeFile>(other->file)) return 0; if (!oldSym->section && !newSym->section && oldSym->value == newSym->value && diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index 85e2fcfc838c8..7844f27139cff 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -211,7 +211,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body, Stmt **last_stmt_ptr = Body->body_end() - 1; Stmt *last_stmt = *last_stmt_ptr; - while (dyn_cast<NullStmt>(last_stmt)) { + while (isa<NullStmt>(last_stmt)) { if (last_stmt_ptr != Body->body_begin()) { last_stmt_ptr--; last_stmt = *last_stmt_ptr; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp index a6e36d81b9503..8b132b54b7e69 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp @@ -353,7 +353,7 @@ class ValidPointerChecker : public Instrumenter { } bool InspectInstruction(llvm::Instruction &i) override { - if (dyn_cast<llvm::LoadInst>(&i) || dyn_cast<llvm::StoreInst>(&i)) + if (isa<llvm::LoadInst>(&i) || isa<llvm::StoreInst>(&i)) RegisterInstruction(i); return true; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index f80dc2b144672..e0e41925f7ef4 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -1255,7 +1255,7 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) { m_decl_map->AddValueToStruct(named_decl, lldb_private::ConstString(name), llvm_value_ptr, *value_size, value_alignment); - } else if (dyn_cast<llvm::Function>(llvm_value_ptr)) { + } else if (isa<llvm::Function>(llvm_value_ptr)) { LLDB_LOG(log, "Function pointers aren't handled right now"); return false; diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 7ce2f1451580f..9473befa6cc34 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -1280,15 +1280,15 @@ clang::QualType PdbAstBuilder::CreateFunctionType( } static bool isTagDecl(clang::DeclContext &context) { - return !!llvm::dyn_cast<clang::TagDecl>(&context); + return llvm::isa<clang::TagDecl>(&context); } static bool isFunctionDecl(clang::DeclContext &context) { - return !!llvm::dyn_cast<clang::FunctionDecl>(&context); + return llvm::isa<clang::FunctionDecl>(&context); } static bool isBlockDecl(clang::DeclContext &context) { - return !!llvm::dyn_cast<clang::BlockDecl>(&context); + return llvm::isa<clang::BlockDecl>(&context); } void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf( diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index db0ae241be7ec..c0547936b6661 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -402,7 +402,7 @@ static size_t ParseFunctionBlocksForPDBSymbol( block = parent_block; else break; - } else if (llvm::dyn_cast<PDBSymbolBlock>(pdb_symbol)) { + } else if (llvm::isa<PDBSymbolBlock>(pdb_symbol)) { auto uid = pdb_symbol->getSymIndexId(); if (parent_block->FindBlockByID(uid)) break; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits