Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/SIL/AddressWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ TransitiveAddressWalker<Impl>::walk(SILValue projectedAddress) {
callVisitUse(op);
continue;
}
if (auto *mdi = dyn_cast<MarkDependenceInst>(user)) {
if (isa<MarkDependenceInst>(user)) {
// If we are the value use of a forwarding markdep, look through it.
transitiveResultUses(op);
continue;
}
if (auto *mdi = dyn_cast<MarkDependenceAddrInst>(user)) {
if (isa<MarkDependenceAddrInst>(user)) {
// The address operand is simply a leaf use.
callVisitUse(op);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoadBorrowInst>(orig)) {
if (isa<LoadBorrowInst>(orig)) {
for (auto *use : markedInst->getConsumingUses()) {
destroys.push_back(cast<DestroyValueInst>(use->getUser()));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace {
}

if (auto DRE = dyn_cast<DeclRefExpr>(expr)) {
if (auto varDecl = dyn_cast<VarDecl>(DRE->getDecl())) {
if (isa<VarDecl>(DRE->getDecl())) {
if (CS.hasType(DRE)) {
LTI.collectedTypes.insert(CS.getType(DRE).getPointer());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10849,7 +10849,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
// which means MetatypeType has to be added after finding a type variable.
if (baseLocator->isLastElement<LocatorPathElt::MemberRefBase>())
baseType = MetatypeType::get(baseType);
} else if (auto *keyPathExpr = getAsExpr<KeyPathExpr>(anchor)) {
} else if (getAsExpr<KeyPathExpr>(anchor)) {
// Key path can't refer to initializers e.g. `\Type.init`
return AllowInvalidRefInKeyPath::forRef(cs, baseType, init, locator);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<os_unfair_lock>
#elseif os(Windows)
private let underlying: UnsafeMutablePointer<SRWLOCK>
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -289,27 +289,27 @@ fileprivate class _Lock {

@discardableResult
func withLock<T>(_ 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
Expand Down
4 changes: 4 additions & 0 deletions stdlib/public/runtime/Backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -318,6 +319,7 @@ bool writeProtectMemory(void *ptr, size_t size) {
return mprotect(ptr, size, PROT_READ) == 0;
}
#endif
#endif

} // namespace

Expand Down Expand Up @@ -1061,6 +1063,7 @@ _swift_backtrace_demangle(const char *mangledName,
return nullptr;
}

#if SWIFT_BACKTRACE_ON_CRASH_SUPPORTED
namespace {

char addr_buf[18];
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down