Skip to content

Commit 054d7b9

Browse files
authored
Merge pull request swiftlang#29713 from CodaFi/unused-unwanted-unloved
[Gardening] Silence Some Warning Spew
2 parents 41adc85 + 1c156db commit 054d7b9

31 files changed

+57
-54
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/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ namespace {
716716

717717
if (auto *var = dyn_cast<VarDecl>(VD)) {
718718
PrintWithColorRAII(OS, TypeColor) << " type='";
719-
if (auto varTy = var->hasInterfaceType())
719+
if (var->hasInterfaceType())
720720
var->getType().print(PrintWithColorRAII(OS, TypeColor).getOS());
721721
else
722722
PrintWithColorRAII(OS, TypeColor) << "<null type>";

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: 2 additions & 2 deletions
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

@@ -213,7 +213,7 @@ DefaultAndMaxAccessLevelRequest::evaluate(Evaluator &evaluator,
213213

214214
AccessLevel maxAccess = AccessLevel::Public;
215215

216-
if (GenericParamList *genericParams = ED->getGenericParams()) {
216+
if (ED->getGenericParams()) {
217217
// Only check the trailing 'where' requirements. Other requirements come
218218
// from the extended type and have already been checked.
219219
DirectlyReferencedTypeDecls typeDecls =

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/IndexSubset.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ using namespace swift;
1616

1717
IndexSubset *
1818
IndexSubset::getFromString(ASTContext &ctx, StringRef string) {
19-
if (string.size() < 0) return nullptr;
2019
unsigned capacity = string.size();
2120
llvm::SmallBitVector indices(capacity);
2221
for (unsigned i : range(capacity)) {

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ ModuleDecl::ReverseFullNameIterator::operator++() {
12181218
if (!current)
12191219
return *this;
12201220

1221-
if (auto *swiftModule = current.dyn_cast<const ModuleDecl *>()) {
1221+
if (current.is<const ModuleDecl *>()) {
12221222
current = nullptr;
12231223
return *this;
12241224
}

lib/AST/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ getObjCObjectRepresentable(Type type, const DeclContext *dc) {
20232023
// DynamicSelfType is always representable in Objective-C, even if
20242024
// the class is not @objc, allowing Self-returning methods to witness
20252025
// @objc protocol requirements.
2026-
if (auto dynSelf = type->getAs<DynamicSelfType>())
2026+
if (type->is<DynamicSelfType>())
20272027
return ForeignRepresentableKind::Object;
20282028

20292029
// @objc classes.
@@ -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,
@@ -4098,7 +4098,7 @@ case TypeKind::Id:
40984098
auto fnTy = cast<SILFunctionType>(base);
40994099
bool changed = false;
41004100

4101-
if (auto subs = fnTy->getSubstitutions()) {
4101+
if (fnTy->getSubstitutions()) {
41024102
#ifndef NDEBUG
41034103
// This interface isn't suitable for updating the substitution map in a
41044104
// substituted SILFunctionType.

lib/AST/TypeCheckRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ SourceLoc WhereClauseOwner::getLoc() const {
363363

364364
void swift::simple_display(llvm::raw_ostream &out,
365365
const WhereClauseOwner &owner) {
366-
if (auto where = owner.source.dyn_cast<TrailingWhereClause *>()) {
366+
if (owner.source.is<TrailingWhereClause *>()) {
367367
simple_display(out, owner.dc->getAsDecl());
368368
} else if (owner.source.is<SpecializeAttr *>()) {
369369
out << "@_specialize";

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");

0 commit comments

Comments
 (0)