Skip to content

Commit 58fe2e1

Browse files
authored
Merge pull request #41682 from tshortli/fix-warnings
NFC: Fix a number of warnings emitted when building swift-frontend
2 parents 7cd3541 + a8ff646 commit 58fe2e1

File tree

13 files changed

+29
-48
lines changed

13 files changed

+29
-48
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
@@ -4456,8 +4456,6 @@ namespace {
44564456
auto setterDecl = cast<AccessorDecl>(afd);
44574457
auto setterImpl = static_cast<FuncDecl *>(context);
44584458

4459-
ASTContext &ctx = setterDecl->getASTContext();
4460-
44614459
Expr *selfExpr = createSelfExpr(setterDecl);
44624460
DeclRefExpr *valueParamRefExpr = createParamRefExpr(setterDecl, 0);
44634461

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,15 @@ class alignas(sizeof(void *) * 2) ActiveActorStatus {
652652
#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION && SWIFT_POINTER_IS_4_BYTES
653653
uint32_t Flags;
654654
dispatch_lock_t DrainLock;
655-
uint32_t Unused;
655+
LLVM_ATTRIBUTE_UNUSED uint32_t Unused = {};
656656
#elif SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION && SWIFT_POINTER_IS_8_BYTES
657657
uint32_t Flags;
658658
dispatch_lock_t DrainLock;
659659
#elif !SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION && SWIFT_POINTER_IS_4_BYTES
660660
uint32_t Flags;
661661
#else /* !SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION && SWIFT_POINTER_IS_8_BYTES */
662662
uint32_t Flags;
663-
uint32_t Unused;
663+
LLVM_ATTRIBUTE_UNUSED uint32_t Unused = {};
664664
#endif
665665
JobRef FirstJob;
666666

@@ -701,7 +701,7 @@ class alignas(sizeof(void *) * 2) ActiveActorStatus {
701701
bool isIdle() const {
702702
bool isIdle = (getActorState() == Idle);
703703
if (isIdle) {
704-
assert(FirstJob == NULL);
704+
assert(!FirstJob);
705705
}
706706
return isIdle;
707707
}
@@ -1063,7 +1063,7 @@ preprocessQueue(JobRef unprocessedStart, JobRef unprocessedEnd, Job *existingPro
10631063
// Preprocess the queue starting from the top
10641064
static Job *
10651065
preprocessQueue(JobRef start) {
1066-
if (start == NULL) {
1066+
if (!start) {
10671067
return NULL;
10681068
}
10691069

@@ -1081,7 +1081,7 @@ preprocessQueue(JobRef start) {
10811081
Job *wellFormedListStart = NULL;
10821082

10831083
auto current = start;
1084-
while (current != NULL) {
1084+
while (current) {
10851085
if (!current.needsPreprocessing()) {
10861086
// We can assume that everything from here onwards as being well formed
10871087
// and sorted
@@ -1241,7 +1241,7 @@ retry:;
12411241
}
12421242

12431243
assert(oldState.getMaxPriority() == JobPriority::Unspecified);
1244-
assert(oldState.getFirstJob() == NULL);
1244+
assert(!oldState.getFirstJob());
12451245
}
12461246

12471247
auto newState = oldState.withRunning();
@@ -1352,7 +1352,7 @@ bool DefaultActorImpl::unlock(bool forceUnlock)
13521352
}
13531353

13541354
auto newState = oldState;
1355-
if (oldState.getFirstJob() != NULL) {
1355+
if (oldState.getFirstJob()) {
13561356
// There is work left to do, don't unlock the actor
13571357
if (!forceUnlock) {
13581358
SWIFT_TASK_DEBUG_LOG("Unlock-ing actor %p failed", this);
@@ -1375,7 +1375,7 @@ bool DefaultActorImpl::unlock(bool forceUnlock)
13751375

13761376
if (newState.isScheduled()) {
13771377
// See ownership rule (6) in DefaultActorImpl
1378-
assert(newState.getFirstJob() != NULL);
1378+
assert(newState.getFirstJob());
13791379
scheduleActorProcessJob(newState.getMaxPriority(), true);
13801380
} else {
13811381
// See ownership rule (5) in DefaultActorImpl

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
}

0 commit comments

Comments
 (0)