diff --git a/include/swift/SIL/AddressWalker.h b/include/swift/SIL/AddressWalker.h index 590e56333155..cbfb50bf65f0 100644 --- a/include/swift/SIL/AddressWalker.h +++ b/include/swift/SIL/AddressWalker.h @@ -314,12 +314,12 @@ TransitiveAddressWalker::walk(SILValue projectedAddress) { callVisitUse(op); continue; } - if (auto *mdi = dyn_cast(user)) { + if (isa(user)) { // If we are the value use of a forwarding markdep, look through it. transitiveResultUses(op); continue; } - if (auto *mdi = dyn_cast(user)) { + if (isa(user)) { // The address operand is simply a leaf use. callVisitUse(op); continue; diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp index b7c843db8487..130ea65dc9eb 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp @@ -512,7 +512,7 @@ void MoveOnlyObjectCheckerPImpl::check( // %1 = load_borrow %0 // %2 = copy_value %1 // %3 = mark_unresolved_non_copyable_value [no_consume_or_assign] %2 - if (auto *lbi = dyn_cast(orig)) { + if (isa(orig)) { for (auto *use : markedInst->getConsumingUses()) { destroys.push_back(cast(use->getUser())); } diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 14b698782298..be2f5231fd7a 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -194,7 +194,7 @@ namespace { } if (auto DRE = dyn_cast(expr)) { - if (auto varDecl = dyn_cast(DRE->getDecl())) { + if (isa(DRE->getDecl())) { if (CS.hasType(DRE)) { LTI.collectedTypes.insert(CS.getType(DRE).getPointer()); } diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 33df65a49c80..de16b7cf0ebf 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -10849,7 +10849,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs, // which means MetatypeType has to be added after finding a type variable. if (baseLocator->isLastElement()) baseType = MetatypeType::get(baseType); - } else if (auto *keyPathExpr = getAsExpr(anchor)) { + } else if (getAsExpr(anchor)) { // Key path can't refer to initializers e.g. `\Type.init` return AllowInvalidRefInKeyPath::forRef(cs, baseType, init, locator); } diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index dbfd21cd852f..0363ce01c271 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -5154,8 +5154,7 @@ void AttributeChecker::checkBackDeployedAttrs( // Unavailable decls cannot be back deployed. auto backDeployedDomain = AvailabilityDomain::forPlatform(Attr->Platform); - if (auto unavailableDomain = - availability.containsUnavailableDomain(backDeployedDomain)) { + if (availability.containsUnavailableDomain(backDeployedDomain)) { auto domainForDiagnostics = backDeployedDomain; llvm::VersionTuple ignoredVersion; diff --git a/stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift b/stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift index cab15d5677e2..2d5752009850 100644 --- a/stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift +++ b/stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift @@ -238,7 +238,7 @@ public struct LocalTestingDistributedActorSystemError: DistributedActorSystemErr @available(SwiftStdlib 5.7, *) @safe fileprivate class _Lock { - #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS) private let underlying: UnsafeMutablePointer #elseif os(Windows) private let underlying: UnsafeMutablePointer @@ -251,7 +251,7 @@ fileprivate class _Lock { #endif init() { - #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS) self.underlying = UnsafeMutablePointer.allocate(capacity: 1) unsafe self.underlying.initialize(to: os_unfair_lock()) #elseif os(Windows) @@ -261,21 +261,21 @@ fileprivate class _Lock { // WASI environment has only a single thread #else self.underlying = UnsafeMutablePointer.allocate(capacity: 1) - guard pthread_mutex_init(self.underlying, nil) == 0 else { + guard unsafe pthread_mutex_init(self.underlying, nil) == 0 else { fatalError("pthread_mutex_init failed") } #endif } deinit { - #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS) // `os_unfair_lock`s do not need to be explicitly destroyed #elseif os(Windows) // `SRWLOCK`s do not need to be explicitly destroyed #elseif os(WASI) // WASI environment has only a single thread #else - guard pthread_mutex_destroy(self.underlying) == 0 else { + guard unsafe pthread_mutex_destroy(self.underlying) == 0 else { fatalError("pthread_mutex_destroy failed") } #endif @@ -289,27 +289,27 @@ fileprivate class _Lock { @discardableResult func withLock(_ body: () -> T) -> T { - #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS) unsafe os_unfair_lock_lock(self.underlying) #elseif os(Windows) AcquireSRWLockExclusive(self.underlying) #elseif os(WASI) // WASI environment has only a single thread #else - guard pthread_mutex_lock(self.underlying) == 0 else { + guard unsafe pthread_mutex_lock(self.underlying) == 0 else { fatalError("pthread_mutex_lock failed") } #endif defer { - #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) + #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS) unsafe os_unfair_lock_unlock(self.underlying) #elseif os(Windows) ReleaseSRWLockExclusive(self.underlying) #elseif os(WASI) // WASI environment has only a single thread #else - guard pthread_mutex_unlock(self.underlying) == 0 else { + guard unsafe pthread_mutex_unlock(self.underlying) == 0 else { fatalError("pthread_mutex_unlock failed") } #endif diff --git a/stdlib/public/runtime/Backtrace.cpp b/stdlib/public/runtime/Backtrace.cpp index 4839fd3d5865..f4b835898b50 100644 --- a/stdlib/public/runtime/Backtrace.cpp +++ b/stdlib/public/runtime/Backtrace.cpp @@ -309,6 +309,7 @@ bool isPrivileged() { } #endif +#if SWIFT_BACKTRACE_ON_CRASH_SUPPORTED #if _WIN32 bool writeProtectMemory(void *ptr, size_t size) { return !!VirtualProtect(ptr, size, PAGE_READONLY, NULL); @@ -318,6 +319,7 @@ bool writeProtectMemory(void *ptr, size_t size) { return mprotect(ptr, size, PROT_READ) == 0; } #endif +#endif } // namespace @@ -1061,6 +1063,7 @@ _swift_backtrace_demangle(const char *mangledName, return nullptr; } +#if SWIFT_BACKTRACE_ON_CRASH_SUPPORTED namespace { char addr_buf[18]; @@ -1117,6 +1120,7 @@ trueOrFalse(OnOffTty oot) { } } // namespace +#endif // N.B. THIS FUNCTION MUST BE SAFE TO USE FROM A CRASH HANDLER. On Linux // and macOS, that means it must be async-signal-safe. On Windows, there diff --git a/tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp b/tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp index d3262c58cd14..bfbb5801abfe 100644 --- a/tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp +++ b/tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp @@ -291,8 +291,7 @@ static void sourcekitdServer_peer_event_handler(xpc_connection_t peer, } else { dispatch_async(requestQueue, handler); } - } else if (xpc_object_t contents = - xpc_dictionary_get_value(event, "ping")) { + } else if (xpc_dictionary_get_value(event, "ping") != nullptr) { // Ping back. xpc_object_t reply = xpc_dictionary_create_reply(event); xpc_release(event);