Skip to content

Commit 1be8913

Browse files
committed
NFC: Fix a number of warnings emitted when building swift-frontend.
1 parent 8c9b429 commit 1be8913

File tree

10 files changed

+13
-35
lines changed

10 files changed

+13
-35
lines changed

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,6 @@ struct ConstExprInfo {
22442244

22452245
class ConstExtractor: public ASTWalker {
22462246
SDKContext &SCtx;
2247-
ASTContext &Ctx;
22482247
SourceManager &SM;
22492248
std::vector<ConstExprInfo> allConsts;
22502249

@@ -2328,7 +2327,7 @@ class ConstExtractor: public ASTWalker {
23282327
return { true, E };
23292328
}
23302329
public:
2331-
ConstExtractor(SDKContext &SCtx, ASTContext &Ctx): SCtx(SCtx), Ctx(Ctx),
2330+
ConstExtractor(SDKContext &SCtx, ASTContext &Ctx): SCtx(SCtx),
23322331
SM(Ctx.SourceMgr) {}
23332332
void extract(ModuleDecl *MD) { MD->walk(*this); }
23342333
std::vector<ConstExprInfo> &getAllConstValues() { return allConsts; }

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,7 +3330,6 @@ Type GenericSignatureBuilder::getCanonicalTypeParameter(Type type) {
33303330
Type currentType = genericParamType;
33313331
SmallVector<AssociatedTypeDecl *, 4> path(initialPath.getPath().begin(),
33323332
initialPath.getPath().end());
3333-
bool simplified = false;
33343333
do {
33353334
CanType currentAnchor = currentType->getCanonicalType();
33363335
if (auto rootNode = Impl->getRewriteTreeRootIfPresent(currentAnchor)) {
@@ -3366,7 +3365,6 @@ Type GenericSignatureBuilder::getCanonicalTypeParameter(Type type) {
33663365
}
33673366

33683367
// Move back to the beginning; we may have opened up other rewrites.
3369-
simplified = true;
33703368
startIndex = 0;
33713369
currentType = genericParamType;
33723370
continue;

lib/AST/NameLookup.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,6 @@ directReferencesForIdentTypeRepr(Evaluator &evaluator,
21742174
DeclContext *dc) {
21752175
DirectlyReferencedTypeDecls current;
21762176

2177-
bool firstComponent = true;
21782177
for (const auto &component : ident->getComponentRange()) {
21792178
// If we already set a declaration, use it.
21802179
if (auto typeDecl = component->getBoundDecl()) {
@@ -2194,7 +2193,6 @@ directReferencesForIdentTypeRepr(Evaluator &evaluator,
21942193
if (current.empty())
21952194
return current;
21962195

2197-
firstComponent = false;
21982196
continue;
21992197
}
22002198

lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,8 +2259,9 @@ ClangImporter::Implementation::Implementation(
22592259
IsReadingBridgingPCH(false),
22602260
CurrentVersion(ImportNameVersion::fromOptions(ctx.LangOpts)),
22612261
Walker(DiagnosticWalker(*this)),
2262+
BuffersForDiagnostics(ctx.SourceMgr),
22622263
BridgingHeaderLookupTable(new SwiftLookupTable(nullptr)),
2263-
BuffersForDiagnostics(ctx.SourceMgr), platformAvailability(ctx.LangOpts),
2264+
platformAvailability(ctx.LangOpts),
22642265
nameImporter(),
22652266
DisableSourceImport(ctx.ClangImporterOpts.DisableSourceImport),
22662267
DWARFImporter(dwarfImporterDelegate) {}
@@ -4587,12 +4588,6 @@ synthesizeBaseClassFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
45874588
casted->setType(baseStruct->getSelfInterfaceType());
45884589
casted->setThrows(false);
45894590

4590-
// If the base class var has a clang decl, that means it's an access into a
4591-
// stored field. Otherwise, we're looking into another base class, so it's a
4592-
// another synthesized accessor.
4593-
AccessSemantics accessKind = baseClassVar->getClangDecl()
4594-
? AccessSemantics::DirectToStorage
4595-
: AccessSemantics::DirectToImplementation;
45964591
Expr *baseMember = nullptr;
45974592
if (auto subscript = dyn_cast<SubscriptDecl>(baseClassVar)) {
45984593
auto paramDecl = getterDecl->getParameters()->get(0);

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4454,8 +4454,6 @@ namespace {
44544454
auto setterDecl = cast<AccessorDecl>(afd);
44554455
auto setterImpl = static_cast<FuncDecl *>(context);
44564456

4457-
ASTContext &ctx = setterDecl->getASTContext();
4458-
44594457
Expr *selfExpr = createSelfExpr(setterDecl);
44604458
DeclRefExpr *valueParamRefExpr = createParamRefExpr(setterDecl, 0);
44614459

lib/IRGen/GenStruct.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ namespace {
429429

430430
void addToAggLowering(IRGenModule &IGM, SwiftAggLowering &lowering,
431431
Size offset) const override {
432-
auto &layout = ClangDecl->getASTContext().getASTRecordLayout(ClangDecl);
433-
434432
forEachNonEmptyBase([&](clang::QualType type, clang::CharUnits offset,
435433
clang::CharUnits) {
436434
lowering.addTypedData(type, offset);

lib/IRGen/Linking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ UniversalLinkageInfo::UniversalLinkageInfo(const llvm::Triple &triple,
8888
bool forcePublicDecls,
8989
bool isStaticLibrary)
9090
: IsELFObject(triple.isOSBinFormatELF()),
91-
UseDLLStorage(useDllStorage(triple)), HasMultipleIGMs(hasMultipleIGMs),
92-
Internalize(isStaticLibrary), ForcePublicDecls(forcePublicDecls) {}
91+
UseDLLStorage(useDllStorage(triple)), Internalize(isStaticLibrary),
92+
HasMultipleIGMs(hasMultipleIGMs), ForcePublicDecls(forcePublicDecls) {}
9393

9494
/// Mangle this entity into the given buffer.
9595
void LinkEntity::mangle(SmallVectorImpl<char> &buffer) const {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,7 +2924,6 @@ bool ConformanceChecker::checkActorIsolation(
29242924
// Ensure that the witness is not actor-isolated in a manner that makes it
29252925
// unsuitable as a witness.
29262926
bool isCrossActor = false;
2927-
bool witnessIsUnsafe = false;
29282927
DiagnosticBehavior behavior = SendableCheckContext(
29292928
Conformance->getDeclContext()).defaultDiagnosticBehavior();
29302929
Type witnessGlobalActor;
@@ -3146,7 +3145,6 @@ bool ConformanceChecker::checkActorIsolation(
31463145
}
31473146

31483147
case ActorIsolationRestriction::GlobalActorUnsafe:
3149-
witnessIsUnsafe = true;
31503148
LLVM_FALLTHROUGH;
31513149

31523150
case ActorIsolationRestriction::GlobalActor: {
@@ -3167,13 +3165,11 @@ bool ConformanceChecker::checkActorIsolation(
31673165

31683166
// Check whether the requirement requires some particular actor isolation.
31693167
Type requirementGlobalActor;
3170-
bool requirementIsUnsafe = false;
31713168
switch (auto requirementIsolation = getActorIsolation(requirement)) {
31723169
case ActorIsolation::ActorInstance:
31733170
llvm_unreachable("There are not actor protocols");
31743171

31753172
case ActorIsolation::GlobalActorUnsafe:
3176-
requirementIsUnsafe = true;
31773173
LLVM_FALLTHROUGH;
31783174

31793175
case ActorIsolation::GlobalActor: {

stdlib/public/Concurrency/Clock.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void swift_get_time(
5858
#else
5959
#error Missing platform continuous time definition
6060
#endif
61-
break;
61+
return;
6262
}
6363
case swift_clock_id_suspending: {
6464
#if defined(__linux__) && HAS_TIME
@@ -87,11 +87,10 @@ void swift_get_time(
8787
#else
8888
#error Missing platform suspending time definition
8989
#endif
90-
break;
90+
return;
9191
}
92-
default:
93-
abort();
9492
}
93+
abort(); // Invalid clock_id
9594
}
9695

9796
SWIFT_EXPORT_FROM(swift_Concurrency)
@@ -118,7 +117,7 @@ switch (clock_id) {
118117
#else
119118
#error Missing platform continuous time definition
120119
#endif
121-
break;
120+
return;
122121
}
123122
case swift_clock_id_suspending: {
124123
struct timespec suspending;
@@ -136,9 +135,8 @@ switch (clock_id) {
136135
#else
137136
#error Missing platform suspending time definition
138137
#endif
139-
break;
138+
return;
140139
}
141-
default:
142-
abort();
143140
}
141+
abort(); // Invalid clock_id
144142
}

stdlib/public/runtime/SwiftObject.mm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,13 +661,12 @@ static bool isBridgeObjectTaggedPointer(void *object) {
661661
auto const objectRef = toPlainObject_unTagged_bridgeObject(object);
662662

663663
#if SWIFT_OBJC_INTEROP
664-
void *objc_ret = nullptr;
665664
if (!isNonNative_unTagged_bridgeObject(object)) {
666665
swift_retain_n(static_cast<HeapObject *>(objectRef), n);
667666
return object;
668667
}
669668
for (int i = 0;i < n; ++i)
670-
objc_ret = objc_retain(static_cast<id>(objectRef));
669+
objc_retain(static_cast<id>(objectRef));
671670
return object;
672671
#else
673672
swift_retain_n(static_cast<HeapObject *>(objectRef), n);
@@ -702,13 +701,12 @@ static bool isBridgeObjectTaggedPointer(void *object) {
702701
auto const objectRef = toPlainObject_unTagged_bridgeObject(object);
703702

704703
#if SWIFT_OBJC_INTEROP
705-
void *objc_ret = nullptr;
706704
if (!isNonNative_unTagged_bridgeObject(object)) {
707705
swift_nonatomic_retain_n(static_cast<HeapObject *>(objectRef), n);
708706
return object;
709707
}
710708
for (int i = 0;i < n; ++i)
711-
objc_ret = objc_retain(static_cast<id>(objectRef));
709+
objc_retain(static_cast<id>(objectRef));
712710
return object;
713711
#else
714712
swift_nonatomic_retain_n(static_cast<HeapObject *>(objectRef), n);

0 commit comments

Comments
 (0)