Skip to content

Commit 34f9b80

Browse files
Merge pull request swiftlang#78750 from AnthonyLatsis/oryza-sativa
[Gardening] Fix some set but not used variables
2 parents cac8297 + a84dfc8 commit 34f9b80

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
@@ -3056,7 +3056,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
30563056
appendIdentifier(interface->getObjCRuntimeNameAsString());
30573057
} else if (UseObjCRuntimeNames && protocol) {
30583058
appendIdentifier(protocol->getObjCRuntimeNameAsString());
3059-
} else if (auto ctsd = dyn_cast<clang::ClassTemplateSpecializationDecl>(namedDecl)) {
3059+
} else if (isa<clang::ClassTemplateSpecializationDecl>(namedDecl)) {
30603060
// If this is a `ClassTemplateSpecializationDecl`, it was
30613061
// imported as a Swift decl with `__CxxTemplateInst...` name.
30623062
// `ClassTemplateSpecializationDecl`'s name does not include information about
@@ -3253,7 +3253,7 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
32533253
appendOperator("YK");
32543254
}
32553255
}
3256-
switch (auto diffKind = fn->getDifferentiabilityKind()) {
3256+
switch (fn->getDifferentiabilityKind()) {
32573257
case DifferentiabilityKind::NonDifferentiable:
32583258
break;
32593259
case DifferentiabilityKind::Forward:
@@ -4164,11 +4164,11 @@ void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,
41644164

41654165
BaseEntitySignature base(decl);
41664166
appendContextOf(decl, base);
4167-
if (auto *varDecl = dyn_cast<VarDecl>(decl)) {
4167+
if (isa<VarDecl>(decl)) {
41684168
appendDeclName(decl);
41694169
appendDeclType(decl, base);
41704170
appendOperator("v", accessorKindCode);
4171-
} else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl)) {
4171+
} else if (isa<SubscriptDecl>(decl)) {
41724172
appendDeclType(decl, base);
41734173

41744174
StringRef privateDiscriminator = getPrivateDiscriminatorIfNecessary(decl);
@@ -4963,7 +4963,7 @@ getPrecheckedLocalContextDiscriminator(const Decl *decl, Identifier name) {
49634963
std::string ASTMangler::mangleAttachedMacroExpansion(
49644964
const Decl *decl, CustomAttr *attr, MacroRole role) {
49654965
if (auto abiDecl = getABIDecl(decl)) {
4966-
return mangleAttachedMacroExpansion(decl, attr, role);
4966+
return mangleAttachedMacroExpansion(abiDecl, attr, role);
49674967
}
49684968

49694969
// 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;
@@ -4136,7 +4136,7 @@ void PrintAST::visitAccessorDecl(AccessorDecl *decl) {
41364136
// Explicitly print 'mutating' and 'nonmutating' if needed.
41374137
printSelfAccessKindModifiersIfNeeded(decl);
41384138

4139-
switch (auto kind = decl->getAccessorKind()) {
4139+
switch (decl->getAccessorKind()) {
41404140
case AccessorKind::Get:
41414141
case AccessorKind::DistributedGet:
41424142
case AccessorKind::Address:
@@ -4773,13 +4773,13 @@ void PrintAST::visitErrorExpr(ErrorExpr *expr) {
47734773

47744774
void PrintAST::visitTernaryExpr(TernaryExpr *expr) {
47754775
if (auto condExpr = expr->getCondExpr()) {
4776-
visit(expr->getCondExpr());
4776+
visit(condExpr);
47774777
}
47784778
Printer << " ? ";
47794779
visit(expr->getThenExpr());
47804780
Printer << " : ";
47814781
if (auto elseExpr = expr->getElseExpr()) {
4782-
visit(expr->getElseExpr());
4782+
visit(elseExpr);
47834783
}
47844784
}
47854785

@@ -6060,7 +6060,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
60606060
} else if (auto *VD = originator.dyn_cast<VarDecl *>()) {
60616061
Printer << "decl = ";
60626062
Printer << VD->getName();
6063-
} else if (auto *EE = originator.dyn_cast<ErrorExpr *>()) {
6063+
} else if (originator.is<ErrorExpr *>()) {
60646064
Printer << "error_expr";
60656065
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
60666066
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
@@ -1701,7 +1701,7 @@ AccessLevel ImportDecl::getAccessLevel() const {
17011701
}
17021702

17031703
bool ImportDecl::isAccessLevelImplicit() const {
1704-
if (auto attr = getAttrs().getAttribute<AccessControlAttr>()) {
1704+
if (getAttrs().hasAttribute<AccessControlAttr>()) {
17051705
return false;
17061706
}
17071707
return true;
@@ -4688,7 +4688,7 @@ static AccessLevel getAdjustedFormalAccess(const ValueDecl *VD,
46884688
if (useDC) {
46894689
// If the use site decl context is PackageUnit, just return
46904690
// the access level that's passed in
4691-
if (auto usePkg = useDC->getPackageContext())
4691+
if (useDC->getPackageContext())
46924692
return access;
46934693
// Check whether we need to modify the access level based on
46944694
// @testable/@_private import attributes.
@@ -8024,7 +8024,7 @@ bool VarDecl::isMemberwiseInitialized(bool preferDeclaredProperties) const {
80248024
// memberwise initializable when it could be used to initialize
80258025
// other stored properties.
80268026
if (hasInitAccessor()) {
8027-
if (auto *init = getAccessor(AccessorKind::Init))
8027+
if (getAccessor(AccessorKind::Init))
80288028
return true;
80298029
}
80308030

@@ -11528,7 +11528,7 @@ ActorIsolation swift::getActorIsolationOfContext(
1152811528
return getClosureActorIsolation(closure);
1152911529
}
1153011530

11531-
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dcToUse)) {
11531+
if (isa<TopLevelCodeDecl>(dcToUse)) {
1153211532
if (dcToUse->isAsyncContext() ||
1153311533
dcToUse->getASTContext().LangOpts.StrictConcurrencyLevel >=
1153411534
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)