Use isa instead of dyn_cast (NFC)
diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp
index 790f11b..de7e4c3 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -68,7 +68,7 @@
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 e132c56..29762b6 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -382,7 +382,7 @@
// 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 @@
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 432d929..b0b882b 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -829,7 +829,7 @@
} 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 4a58fe8..a0ae441 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -155,7 +155,7 @@
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 d25f329..54f0242 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1346,7 +1346,7 @@
// 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 f1b0c5c..07b6067 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2085,7 +2085,7 @@
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 23f8d3e..2030149 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -550,7 +550,7 @@
}
// 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 @@
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 85e2fcf..7844f27 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -211,7 +211,7 @@
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 a6e36d8..8b132b54 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -353,7 +353,7 @@
}
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 f80dc2b..e0e4192 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1255,7 +1255,7 @@
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 7ce2f14..9473bef 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1280,15 +1280,15 @@
}
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 db0ae24..c054793 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -402,7 +402,7 @@
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;