Skip to content

Commit d2360d2

Browse files
committed
[Gardening] dyn_cast -> isa
1 parent a7f113d commit d2360d2

19 files changed

+35
-33
lines changed

include/swift/SIL/AbstractionPattern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ class AbstractionPattern {
675675
isa<GenericTypeParamType>(type)) {
676676
return true;
677677
}
678-
if (auto archetype = dyn_cast<ArchetypeType>(type)) {
678+
if (isa<ArchetypeType>(type)) {
679679
return true;
680680
}
681681
return false;

lib/AST/ASTScopeCreation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class ScopeCreator final {
523523
// get inactive nodes that nest in active clauses
524524
for (auto n : clause.Elements) {
525525
if (auto *const d = n.dyn_cast<Decl *>())
526-
if (auto *const icd = dyn_cast<IfConfigDecl>(d))
526+
if (isa<IfConfigDecl>(d))
527527
expandIfConfigClausesInto(expansion, {d}, true);
528528
}
529529
} else if (includeInactiveIfConfigClauses) {
@@ -1776,7 +1776,7 @@ void ScopeCreator::forEachClosureIn(
17761776
return {true, E};
17771777
}
17781778
std::pair<bool, Stmt *> walkToStmtPre(Stmt *S) override {
1779-
if (auto *bs = dyn_cast<BraceStmt>(S)) { // closures hidden in here
1779+
if (isa<BraceStmt>(S)) { // closures hidden in here
17801780
return {true, S};
17811781
}
17821782
return {false, S};
@@ -2132,7 +2132,7 @@ class LocalizableDeclContextCollector : public ASTWalker {
21322132
auto f = SM.getIdentifierForBuffer(bufID);
21332133
auto lin = SM.getLineNumber(loc);
21342134
if (f.endswith(file) && lin == line)
2135-
if (auto *v = dyn_cast<PatternBindingDecl>(D))
2135+
if (isa<PatternBindingDecl>(D))
21362136
llvm::errs() << "*** catchForDebugging: " << lin << " ***\n";
21372137
}
21382138
};

lib/AST/AccessRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ AccessLevelRequest::evaluate(Evaluator &evaluator, ValueDecl *D) const {
6868

6969
// Special case for generic parameters; we just give them a dummy
7070
// access level.
71-
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(D)) {
71+
if (isa<GenericTypeParamDecl>(D)) {
7272
return AccessLevel::Internal;
7373
}
7474

lib/AST/Decl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ Expr *AbstractFunctionDecl::getSingleExpressionBody() const {
645645
if (auto *stmt = body.dyn_cast<Stmt *>()) {
646646
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
647647
return returnStmt->getResult();
648-
} else if (auto *failStmt = dyn_cast<FailStmt>(stmt)) {
648+
} else if (isa<FailStmt>(stmt)) {
649649
// We can only get to this point if we're a type-checked ConstructorDecl
650650
// which was originally spelled init?(...) { nil }.
651651
//
@@ -663,7 +663,7 @@ void AbstractFunctionDecl::setSingleExpressionBody(Expr *NewBody) {
663663
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
664664
returnStmt->setResult(NewBody);
665665
return;
666-
} else if (auto *failStmt = dyn_cast<FailStmt>(stmt)) {
666+
} else if (isa<FailStmt>(stmt)) {
667667
// We can only get to this point if we're a type-checked ConstructorDecl
668668
// which was originally spelled init?(...) { nil }.
669669
//
@@ -780,7 +780,7 @@ bool Decl::isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic) const {
780780
FU->getKind() != FileUnitKind::SerializedAST)
781781
return false;
782782

783-
if (auto PD = dyn_cast<ProtocolDecl>(D)) {
783+
if (isa<ProtocolDecl>(D)) {
784784
if (treatNonBuiltinProtocolsAsPublic)
785785
return false;
786786
}
@@ -2657,7 +2657,7 @@ static Type mapSignatureFunctionType(ASTContext &ctx, Type type,
26572657

26582658
// Functions and subscripts cannot overload differing only in opaque return
26592659
// types. Replace the opaque type with `Any`.
2660-
if (auto opaque = type->getAs<OpaqueTypeArchetypeType>()) {
2660+
if (type->is<OpaqueTypeArchetypeType>()) {
26612661
type = ProtocolCompositionType::get(ctx, {}, /*hasAnyObject*/ false);
26622662
}
26632663

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,7 +3442,7 @@ Type DependentMemberType::substBaseType(Type substBase,
34423442
Type DependentMemberType::substRootParam(Type newRoot,
34433443
LookupConformanceFn lookupConformance){
34443444
auto base = getBase();
3445-
if (auto param = base->getAs<GenericTypeParamType>()) {
3445+
if (base->is<GenericTypeParamType>()) {
34463446
return substBaseType(newRoot, lookupConformance);
34473447
}
34483448
if (auto depMem = base->getAs<DependentMemberType>()) {
@@ -3633,7 +3633,7 @@ static Type substType(Type derivedType,
36333633
if (isa<GenericTypeParamType>(substOrig))
36343634
return ErrorType::get(type);
36353635

3636-
if (auto primaryArchetype = dyn_cast<PrimaryArchetypeType>(substOrig))
3636+
if (isa<PrimaryArchetypeType>(substOrig))
36373637
return ErrorType::get(type);
36383638

36393639
// Opened existentials cannot be substituted in this manner,

lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@ static StringRef baseNameForImage(const JobAction *JA, const OutputInfo &OI,
23472347
if (JA->size() == 1 && OI.ModuleNameIsFallback && BaseInput != "-")
23482348
return llvm::sys::path::stem(BaseInput);
23492349

2350-
if (auto link = dyn_cast<StaticLinkJobAction>(JA)) {
2350+
if (isa<StaticLinkJobAction>(JA)) {
23512351
Buffer = "lib";
23522352
Buffer.append(BaseName);
23532353
Buffer.append(Triple.isOSWindows() ? ".lib" : ".a");

lib/IDE/CodeCompletion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5239,7 +5239,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
52395239
}
52405240
if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(ParsedExpr)) {
52415241
Lookup.setIsSelfRefExpr(DRE->getDecl()->getFullName() == Context.Id_self);
5242-
} else if (auto *SRE = dyn_cast_or_null<SuperRefExpr>(ParsedExpr)) {
5242+
} else if (ParsedExpr && isa<SuperRefExpr>(ParsedExpr)) {
52435243
Lookup.setIsSuperRefExpr();
52445244
}
52455245

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6397,7 +6397,7 @@ void Parser::parseAbstractFunctionBody(AbstractFunctionDecl *AFD) {
63976397
return;
63986398
}
63996399
}
6400-
if (auto F = dyn_cast<FuncDecl>(AFD)) {
6400+
if (isa<FuncDecl>(AFD)) {
64016401
auto RS = new (Context) ReturnStmt(SourceLoc(), E);
64026402
BS->setFirstElement(RS);
64036403
AFD->setHasSingleExpressionBody();

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static bool computeLiveness(CopyPropagationState &pass) {
615615
// point of the end_borrow.
616616
if (auto *BBI = dyn_cast<BeginBorrowInst>(user)) {
617617
for (Operand *use : BBI->getUses()) {
618-
if (auto *EBI = dyn_cast<EndBorrowInst>(use->getUser()))
618+
if (isa<EndBorrowInst>(use->getUser()))
619619
computeUseLiveness(use, pass);
620620
}
621621
continue;

lib/Sema/BuilderTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class BuilderClosureVisitor
266266
continue;
267267

268268
// Skip #warning/#error; we'll handle them when applying the builder.
269-
if (auto poundDiag = dyn_cast<PoundDiagnosticDecl>(decl)) {
269+
if (isa<PoundDiagnosticDecl>(decl)) {
270270
continue;
271271
}
272272

0 commit comments

Comments
 (0)