Skip to content

Commit 8aaac80

Browse files
MaxGraeyjoker-eph
andauthored
[NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (#137393)
Also fix some typos in comments --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
1 parent ac583df commit 8aaac80

File tree

26 files changed

+39
-40
lines changed

26 files changed

+39
-40
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10052,9 +10052,10 @@ void CheckFreeArgumentsAddressof(Sema &S, const std::string &CalleeName,
1005210052
const UnaryOperator *UnaryExpr) {
1005310053
if (const auto *Lvalue = dyn_cast<DeclRefExpr>(UnaryExpr->getSubExpr())) {
1005410054
const Decl *D = Lvalue->getDecl();
10055-
if (isa<DeclaratorDecl>(D))
10056-
if (!dyn_cast<DeclaratorDecl>(D)->getType()->isReferenceType())
10055+
if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
10056+
if (!DD->getType()->isReferenceType())
1005710057
return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
10058+
}
1005810059
}
1005910060

1006010061
if (const auto *Lvalue = dyn_cast<MemberExpr>(UnaryExpr->getSubExpr()))

clang/lib/Sema/SemaModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ static bool checkExportedDecl(Sema &S, Decl *D, SourceLocation BlockStart) {
942942
// HLSL: export declaration is valid only on functions
943943
if (S.getLangOpts().HLSL) {
944944
// Export-within-export was already diagnosed in ActOnStartExportDecl
945-
if (!dyn_cast<FunctionDecl>(D) && !dyn_cast<ExportDecl>(D)) {
945+
if (!isa<FunctionDecl, ExportDecl>(D)) {
946946
S.Diag(D->getBeginLoc(), diag::err_hlsl_export_not_on_function);
947947
D->setInvalidDecl();
948948
return false;

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ bool SemaOpenMP::isInOpenMPTargetExecutionDirective() const {
23072307

23082308
bool SemaOpenMP::isOpenMPRebuildMemberExpr(ValueDecl *D) {
23092309
// Only rebuild for Field.
2310-
if (!dyn_cast<FieldDecl>(D))
2310+
if (!isa<FieldDecl>(D))
23112311
return false;
23122312
DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(
23132313
D,

clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class RawPtrRefLocalVarsChecker
356356
SmallString<100> Buf;
357357
llvm::raw_svector_ostream Os(Buf);
358358

359-
if (dyn_cast<ParmVarDecl>(V)) {
359+
if (isa<ParmVarDecl>(V)) {
360360
Os << "Assignment to an " << ptrKind() << " parameter ";
361361
printQuotedQualifiedName(Os, V);
362362
Os << " is unsafe.";

lld/MachO/SymbolTable.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
518518

519519
// If in the symbol table and not undefined.
520520
if (const Symbol *s = symtab->find(newName))
521-
if (dyn_cast<Undefined>(s) == nullptr)
521+
if (!isa<Undefined>(s))
522522
return s;
523523

524524
return nullptr;
@@ -567,8 +567,7 @@ static const Symbol *getAlternativeSpelling(const Undefined &sym,
567567
if (name.equals_insensitive(it.first))
568568
return it.second;
569569
for (Symbol *sym : symtab->getSymbols())
570-
if (dyn_cast<Undefined>(sym) == nullptr &&
571-
name.equals_insensitive(sym->getName()))
570+
if (!isa<Undefined>(sym) && name.equals_insensitive(sym->getName()))
572571
return sym;
573572

574573
// The reference may be a mangled name while the definition is not. Suggest a

llvm/include/llvm/Analysis/LoopInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
529529
}
530530

531531
// Return true if a new use of V added in ExitBB would require an LCSSA PHI
532-
// to be inserted at the begining of the block. Note that V is assumed to
532+
// to be inserted at the beginning of the block. Note that V is assumed to
533533
// dominate ExitBB, and ExitBB must be the exit block of some loop. The
534534
// IR is assumed to be in LCSSA form before the planned insertion.
535535
bool wouldBeOutOfLoopUseRequiringLCSSA(const Value *V,

llvm/lib/Bitcode/Reader/MetadataLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class MetadataLoader::MetadataLoaderImpl {
558558
SetVector<Metadata *> EntitiesToRemove;
559559
for (Metadata *Op : CU->getImportedEntities()->operands()) {
560560
auto *IE = cast<DIImportedEntity>(Op);
561-
if (dyn_cast_or_null<DILocalScope>(IE->getScope())) {
561+
if (isa_and_nonnull<DILocalScope>(IE->getScope())) {
562562
EntitiesToRemove.insert(IE);
563563
}
564564
}

llvm/lib/IR/Verifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6584,7 +6584,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
65846584
for (BasicBlock *ColorFirstBB : CV)
65856585
if (auto It = ColorFirstBB->getFirstNonPHIIt();
65866586
It != ColorFirstBB->end())
6587-
if (dyn_cast_or_null<FuncletPadInst>(&*It))
6587+
if (isa_and_nonnull<FuncletPadInst>(&*It))
65886588
InEHFunclet = true;
65896589

65906590
// Check for funclet operand bundle

llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ bool WebAssemblyTTIImpl::isProfitableToSinkOperands(
294294

295295
Value *V = I->getOperand(1);
296296
// We dont need to sink constant splat.
297-
if (dyn_cast<Constant>(V))
297+
if (isa<Constant>(V))
298298
return false;
299299

300300
if (match(V, m_Shuffle(m_InsertElt(m_Value(), m_Value(), m_ZeroInt()),

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ LLVMTypeConverter::promoteOperands(Location loc, ValueRange opOperands,
755755
if (useBarePtrCallConv) {
756756
// For the bare-ptr calling convention, we only have to extract the
757757
// aligned pointer of a memref.
758-
if (dyn_cast<MemRefType>(operand.getType())) {
758+
if (isa<MemRefType>(operand.getType())) {
759759
MemRefDescriptor desc(llvmOperand);
760760
llvmOperand = desc.alignedPtr(builder, loc);
761761
} else if (isa<UnrankedMemRefType>(operand.getType())) {

0 commit comments

Comments
 (0)