Skip to content

Commit a84dfc8

Browse files
committed
[Gardening] Fix some set but not used variables
1 parent 71015c6 commit a84dfc8

File tree

89 files changed

+169
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+169
-181
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Type ASTBuilder::createNominalType(GenericTypeDecl *decl, Type parent) {
155155
return Type();
156156

157157
// If the declaration is generic, fail.
158-
if (auto list = nominalDecl->getGenericParams())
158+
if (nominalDecl->isGeneric())
159159
return Type();
160160

161161
// Imported types can be renamed to be members of other (non-generic)

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5692,7 +5692,7 @@ namespace {
56925692
} else if (auto *VD = originator.dyn_cast<VarDecl *>()) {
56935693
printFieldQuotedRaw([&](raw_ostream &OS) { VD->dumpRef(OS); },
56945694
Label::optional("originating_var"), DeclColor);
5695-
} else if (auto *EE = originator.dyn_cast<ErrorExpr *>()) {
5695+
} else if (originator.is<ErrorExpr *>()) {
56965696
printFlag("error_expr");
56975697
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
56985698
printRec(DMT, Label::always("dependent_member_type"));

lib/AST/ASTMangler.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
30503050
appendIdentifier(interface->getObjCRuntimeNameAsString());
30513051
} else if (UseObjCRuntimeNames && protocol) {
30523052
appendIdentifier(protocol->getObjCRuntimeNameAsString());
3053-
} else if (auto ctsd = dyn_cast<clang::ClassTemplateSpecializationDecl>(namedDecl)) {
3053+
} else if (isa<clang::ClassTemplateSpecializationDecl>(namedDecl)) {
30543054
// If this is a `ClassTemplateSpecializationDecl`, it was
30553055
// imported as a Swift decl with `__CxxTemplateInst...` name.
30563056
// `ClassTemplateSpecializationDecl`'s name does not include information about
@@ -3247,7 +3247,7 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
32473247
appendOperator("YK");
32483248
}
32493249
}
3250-
switch (auto diffKind = fn->getDifferentiabilityKind()) {
3250+
switch (fn->getDifferentiabilityKind()) {
32513251
case DifferentiabilityKind::NonDifferentiable:
32523252
break;
32533253
case DifferentiabilityKind::Forward:
@@ -4158,11 +4158,11 @@ void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,
41584158

41594159
BaseEntitySignature base(decl);
41604160
appendContextOf(decl, base);
4161-
if (auto *varDecl = dyn_cast<VarDecl>(decl)) {
4161+
if (isa<VarDecl>(decl)) {
41624162
appendDeclName(decl);
41634163
appendDeclType(decl, base);
41644164
appendOperator("v", accessorKindCode);
4165-
} else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl)) {
4165+
} else if (isa<SubscriptDecl>(decl)) {
41664166
appendDeclType(decl, base);
41674167

41684168
StringRef privateDiscriminator = getPrivateDiscriminatorIfNecessary(decl);
@@ -4957,7 +4957,7 @@ getPrecheckedLocalContextDiscriminator(const Decl *decl, Identifier name) {
49574957
std::string ASTMangler::mangleAttachedMacroExpansion(
49584958
const Decl *decl, CustomAttr *attr, MacroRole role) {
49594959
if (auto abiDecl = getABIDecl(decl)) {
4960-
return mangleAttachedMacroExpansion(decl, attr, role);
4960+
return mangleAttachedMacroExpansion(abiDecl, attr, role);
49614961
}
49624962

49634963
// FIXME(kavon): using the decl causes a cycle. Is a null base fine?

lib/AST/ASTNode.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ bool ASTNode::isImplicit() const {
7979
return D->isImplicit();
8080
if (const auto *P = this->dyn_cast<Pattern*>())
8181
return P->isImplicit();
82-
if (const auto *T = this->dyn_cast<TypeRepr*>())
82+
if (this->is<TypeRepr *>())
8383
return false;
84-
if (const auto *C = this->dyn_cast<StmtConditionElement *>())
84+
if (this->is<StmtConditionElement *>())
8585
return false;
86-
if (const auto *I = this->dyn_cast<CaseLabelItem *>())
86+
if (this->is<CaseLabelItem *>())
8787
return false;
8888
llvm_unreachable("unsupported AST node");
8989
}
@@ -124,9 +124,9 @@ void ASTNode::dump(raw_ostream &OS, unsigned Indent) const {
124124
P->dump(OS, Indent);
125125
else if (auto T = dyn_cast<TypeRepr*>())
126126
T->print(OS);
127-
else if (auto *C = dyn_cast<StmtConditionElement *>())
127+
else if (is<StmtConditionElement *>())
128128
OS.indent(Indent) << "(statement condition)";
129-
else if (auto *I = dyn_cast<CaseLabelItem *>()) {
129+
else if (is<CaseLabelItem *>()) {
130130
OS.indent(Indent) << "(case label item)";
131131
} else
132132
llvm_unreachable("unsupported AST node");

lib/AST/ASTPrinter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static bool isPrespecilizationDeclWithTarget(const ValueDecl *vd) {
151151
for (auto *attr : vd->getAttrs().getAttributes<SpecializeAttr>()) {
152152
if (!attr->isExported())
153153
continue;
154-
if (auto *targetFun = attr->getTargetFunctionDecl(vd))
154+
if (attr->getTargetFunctionDecl(vd))
155155
return true;
156156
}
157157
return false;
@@ -4132,7 +4132,7 @@ void PrintAST::visitAccessorDecl(AccessorDecl *decl) {
41324132
// Explicitly print 'mutating' and 'nonmutating' if needed.
41334133
printSelfAccessKindModifiersIfNeeded(decl);
41344134

4135-
switch (auto kind = decl->getAccessorKind()) {
4135+
switch (decl->getAccessorKind()) {
41364136
case AccessorKind::Get:
41374137
case AccessorKind::DistributedGet:
41384138
case AccessorKind::Address:
@@ -4769,13 +4769,13 @@ void PrintAST::visitErrorExpr(ErrorExpr *expr) {
47694769

47704770
void PrintAST::visitTernaryExpr(TernaryExpr *expr) {
47714771
if (auto condExpr = expr->getCondExpr()) {
4772-
visit(expr->getCondExpr());
4772+
visit(condExpr);
47734773
}
47744774
Printer << " ? ";
47754775
visit(expr->getThenExpr());
47764776
Printer << " : ";
47774777
if (auto elseExpr = expr->getElseExpr()) {
4778-
visit(expr->getElseExpr());
4778+
visit(elseExpr);
47794779
}
47804780
}
47814781

@@ -6056,7 +6056,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
60566056
} else if (auto *VD = originator.dyn_cast<VarDecl *>()) {
60576057
Printer << "decl = ";
60586058
Printer << VD->getName();
6059-
} else if (auto *EE = originator.dyn_cast<ErrorExpr *>()) {
6059+
} else if (originator.is<ErrorExpr *>()) {
60606060
Printer << "error_expr";
60616061
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
60626062
visit(DMT);

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ class Verifier : public ASTWalker {
11021102
resultType = FD->mapTypeIntoContext(resultType);
11031103
} else if (auto closure = dyn_cast<AbstractClosureExpr>(func)) {
11041104
resultType = closure->getResultType();
1105-
} else if (auto *CD = dyn_cast<ConstructorDecl>(func)) {
1105+
} else if (isa<ConstructorDecl>(func)) {
11061106
resultType = TupleType::getEmpty(Ctx);
11071107
} else {
11081108
resultType = TupleType::getEmpty(Ctx);

lib/AST/ASTWalker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
12811281

12821282
for (auto &origComponent : components) {
12831283
auto component = origComponent;
1284-
switch (auto kind = component.getKind()) {
1284+
switch (component.getKind()) {
12851285
case KeyPathExpr::Component::Kind::Subscript:
12861286
case KeyPathExpr::Component::Kind::UnresolvedSubscript: {
12871287
if (auto *newArgs = doIt(component.getSubscriptArgs())) {

lib/AST/Attr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void OpenedTypeAttr::printImpl(ASTPrinter &printer,
267267
printer << "(\"" << getUUID() << "\"";
268268
if (auto constraintType = getConstraintType()) {
269269
printer << ", ";
270-
getConstraintType()->print(printer, options);
270+
constraintType->print(printer, options);
271271
}
272272
printer << ")";
273273
printer.printStructurePost(PrintStructureKind::BuiltinAttribute);

lib/AST/Decl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ AccessLevel ImportDecl::getAccessLevel() const {
16911691
}
16921692

16931693
bool ImportDecl::isAccessLevelImplicit() const {
1694-
if (auto attr = getAttrs().getAttribute<AccessControlAttr>()) {
1694+
if (getAttrs().hasAttribute<AccessControlAttr>()) {
16951695
return false;
16961696
}
16971697
return true;
@@ -4678,7 +4678,7 @@ static AccessLevel getAdjustedFormalAccess(const ValueDecl *VD,
46784678
if (useDC) {
46794679
// If the use site decl context is PackageUnit, just return
46804680
// the access level that's passed in
4681-
if (auto usePkg = useDC->getPackageContext())
4681+
if (useDC->getPackageContext())
46824682
return access;
46834683
// Check whether we need to modify the access level based on
46844684
// @testable/@_private import attributes.
@@ -8013,7 +8013,7 @@ bool VarDecl::isMemberwiseInitialized(bool preferDeclaredProperties) const {
80138013
// memberwise initializable when it could be used to initialize
80148014
// other stored properties.
80158015
if (hasInitAccessor()) {
8016-
if (auto *init = getAccessor(AccessorKind::Init))
8016+
if (getAccessor(AccessorKind::Init))
80178017
return true;
80188018
}
80198019

@@ -11509,7 +11509,7 @@ ActorIsolation swift::getActorIsolationOfContext(
1150911509
return getClosureActorIsolation(closure);
1151011510
}
1151111511

11512-
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dcToUse)) {
11512+
if (isa<TopLevelCodeDecl>(dcToUse)) {
1151311513
if (dcToUse->isAsyncContext() ||
1151411514
dcToUse->getASTContext().LangOpts.StrictConcurrencyLevel >=
1151511515
StrictConcurrency::Complete) {

lib/AST/DistributedDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Type swift::getConcreteReplacementForProtocolActorSystemType(
169169
}
170170

171171
/// === Maybe the value is declared in a protocol?
172-
if (auto protocol = DC->getSelfProtocolDecl()) {
172+
if (DC->getSelfProtocolDecl()) {
173173
GenericSignature signature;
174174
if (auto *genericContext = anyValue->getAsGenericContext()) {
175175
signature = genericContext->getGenericSignature();

0 commit comments

Comments
 (0)