Skip to content

Commit 8f2d5a7

Browse files
authored
Merge pull request #80321 from tshortli/warnings
2 parents 2fb76a4 + 5dc7a20 commit 8f2d5a7

File tree

8 files changed

+20
-18
lines changed

8 files changed

+20
-18
lines changed

include/swift/SIL/AddressWalker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ TransitiveAddressWalker<Impl>::walk(SILValue projectedAddress) {
314314
callVisitUse(op);
315315
continue;
316316
}
317-
if (auto *mdi = dyn_cast<MarkDependenceInst>(user)) {
317+
if (isa<MarkDependenceInst>(user)) {
318318
// If we are the value use of a forwarding markdep, look through it.
319319
transitiveResultUses(op);
320320
continue;
321321
}
322-
if (auto *mdi = dyn_cast<MarkDependenceAddrInst>(user)) {
322+
if (isa<MarkDependenceAddrInst>(user)) {
323323
// The address operand is simply a leaf use.
324324
callVisitUse(op);
325325
continue;

lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ void MoveOnlyObjectCheckerPImpl::check(
512512
// %1 = load_borrow %0
513513
// %2 = copy_value %1
514514
// %3 = mark_unresolved_non_copyable_value [no_consume_or_assign] %2
515-
if (auto *lbi = dyn_cast<LoadBorrowInst>(orig)) {
515+
if (isa<LoadBorrowInst>(orig)) {
516516
for (auto *use : markedInst->getConsumingUses()) {
517517
destroys.push_back(cast<DestroyValueInst>(use->getUser()));
518518
}

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ namespace {
194194
}
195195

196196
if (auto DRE = dyn_cast<DeclRefExpr>(expr)) {
197-
if (auto varDecl = dyn_cast<VarDecl>(DRE->getDecl())) {
197+
if (isa<VarDecl>(DRE->getDecl())) {
198198
if (CS.hasType(DRE)) {
199199
LTI.collectedTypes.insert(CS.getType(DRE).getPointer());
200200
}

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10849,7 +10849,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
1084910849
// which means MetatypeType has to be added after finding a type variable.
1085010850
if (baseLocator->isLastElement<LocatorPathElt::MemberRefBase>())
1085110851
baseType = MetatypeType::get(baseType);
10852-
} else if (auto *keyPathExpr = getAsExpr<KeyPathExpr>(anchor)) {
10852+
} else if (getAsExpr<KeyPathExpr>(anchor)) {
1085310853
// Key path can't refer to initializers e.g. `\Type.init`
1085410854
return AllowInvalidRefInKeyPath::forRef(cs, baseType, init, locator);
1085510855
}

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5129,8 +5129,7 @@ void AttributeChecker::checkBackDeployedAttrs(
51295129

51305130
// Unavailable decls cannot be back deployed.
51315131
auto backDeployedDomain = AvailabilityDomain::forPlatform(Attr->Platform);
5132-
if (auto unavailableDomain =
5133-
availability.containsUnavailableDomain(backDeployedDomain)) {
5132+
if (availability.containsUnavailableDomain(backDeployedDomain)) {
51345133
auto domainForDiagnostics = backDeployedDomain;
51355134
llvm::VersionTuple ignoredVersion;
51365135

stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public struct LocalTestingDistributedActorSystemError: DistributedActorSystemErr
238238
@available(SwiftStdlib 5.7, *)
239239
@safe
240240
fileprivate class _Lock {
241-
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
241+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
242242
private let underlying: UnsafeMutablePointer<os_unfair_lock>
243243
#elseif os(Windows)
244244
private let underlying: UnsafeMutablePointer<SRWLOCK>
@@ -251,7 +251,7 @@ fileprivate class _Lock {
251251
#endif
252252

253253
init() {
254-
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
254+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
255255
self.underlying = UnsafeMutablePointer.allocate(capacity: 1)
256256
unsafe self.underlying.initialize(to: os_unfair_lock())
257257
#elseif os(Windows)
@@ -261,21 +261,21 @@ fileprivate class _Lock {
261261
// WASI environment has only a single thread
262262
#else
263263
self.underlying = UnsafeMutablePointer.allocate(capacity: 1)
264-
guard pthread_mutex_init(self.underlying, nil) == 0 else {
264+
guard unsafe pthread_mutex_init(self.underlying, nil) == 0 else {
265265
fatalError("pthread_mutex_init failed")
266266
}
267267
#endif
268268
}
269269

270270
deinit {
271-
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
271+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
272272
// `os_unfair_lock`s do not need to be explicitly destroyed
273273
#elseif os(Windows)
274274
// `SRWLOCK`s do not need to be explicitly destroyed
275275
#elseif os(WASI)
276276
// WASI environment has only a single thread
277277
#else
278-
guard pthread_mutex_destroy(self.underlying) == 0 else {
278+
guard unsafe pthread_mutex_destroy(self.underlying) == 0 else {
279279
fatalError("pthread_mutex_destroy failed")
280280
}
281281
#endif
@@ -289,27 +289,27 @@ fileprivate class _Lock {
289289

290290
@discardableResult
291291
func withLock<T>(_ body: () -> T) -> T {
292-
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
292+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
293293
unsafe os_unfair_lock_lock(self.underlying)
294294
#elseif os(Windows)
295295
AcquireSRWLockExclusive(self.underlying)
296296
#elseif os(WASI)
297297
// WASI environment has only a single thread
298298
#else
299-
guard pthread_mutex_lock(self.underlying) == 0 else {
299+
guard unsafe pthread_mutex_lock(self.underlying) == 0 else {
300300
fatalError("pthread_mutex_lock failed")
301301
}
302302
#endif
303303

304304
defer {
305-
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
305+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
306306
unsafe os_unfair_lock_unlock(self.underlying)
307307
#elseif os(Windows)
308308
ReleaseSRWLockExclusive(self.underlying)
309309
#elseif os(WASI)
310310
// WASI environment has only a single thread
311311
#else
312-
guard pthread_mutex_unlock(self.underlying) == 0 else {
312+
guard unsafe pthread_mutex_unlock(self.underlying) == 0 else {
313313
fatalError("pthread_mutex_unlock failed")
314314
}
315315
#endif

stdlib/public/runtime/Backtrace.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ bool isPrivileged() {
309309
}
310310
#endif
311311

312+
#if SWIFT_BACKTRACE_ON_CRASH_SUPPORTED
312313
#if _WIN32
313314
bool writeProtectMemory(void *ptr, size_t size) {
314315
return !!VirtualProtect(ptr, size, PAGE_READONLY, NULL);
@@ -318,6 +319,7 @@ bool writeProtectMemory(void *ptr, size_t size) {
318319
return mprotect(ptr, size, PROT_READ) == 0;
319320
}
320321
#endif
322+
#endif
321323

322324
} // namespace
323325

@@ -1061,6 +1063,7 @@ _swift_backtrace_demangle(const char *mangledName,
10611063
return nullptr;
10621064
}
10631065

1066+
#if SWIFT_BACKTRACE_ON_CRASH_SUPPORTED
10641067
namespace {
10651068

10661069
char addr_buf[18];
@@ -1117,6 +1120,7 @@ trueOrFalse(OnOffTty oot) {
11171120
}
11181121

11191122
} // namespace
1123+
#endif
11201124

11211125
// N.B. THIS FUNCTION MUST BE SAFE TO USE FROM A CRASH HANDLER. On Linux
11221126
// and macOS, that means it must be async-signal-safe. On Windows, there

tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ static void sourcekitdServer_peer_event_handler(xpc_connection_t peer,
291291
} else {
292292
dispatch_async(requestQueue, handler);
293293
}
294-
} else if (xpc_object_t contents =
295-
xpc_dictionary_get_value(event, "ping")) {
294+
} else if (xpc_dictionary_get_value(event, "ping") != nullptr) {
296295
// Ping back.
297296
xpc_object_t reply = xpc_dictionary_create_reply(event);
298297
xpc_release(event);

0 commit comments

Comments
 (0)