Commit Graph

46338 Commits

Author SHA1 Message Date
Konrad 'ktoso' Malawski
03774d245a fix some tests due to diagnostic rewording 2025-07-15 11:16:13 +09:00
Konrad 'ktoso' Malawski
f52f445358 [Concurrency] add fixit to add final to non-sendable class -> Sendable
The previous message was just suggesting unchecked Sendable, but instead
we should be suggesting to add final to the class. We also don't
outright suggest using unchecked Sendable -- following
https://github.com/swiftlang/swift/pull/81738 precedent.

Resolves rdar://155790695
2025-07-15 10:42:25 +09:00
Allan Shortlidge
d09e117dc0 AST: Canonicalize platform versions for @backDeployed attrs.
Also, diagnose invalid platform versions.

Part of rdar://155558161.
2025-07-14 16:40:16 -07:00
Allan Shortlidge
910989c2c2 AST: Store parsed version in OriginallyDefinedInAttr instead of canonical.
Canonicalize the version on-demand instead.

NFC, part of rdar://155558161.
2025-07-14 16:04:04 -07:00
Hamish Knight
3244bffe71 [CS] Handle TVO_CanBindToPack in mergeEquivalenceClasses
Previously we could incorrectly propagate `TVO_CanBindToPack` to a
type variable that cannot bound to a pack type.
2025-07-14 12:44:23 +01:00
Augusto Noronha
2211d9fcd7 Merge pull request #82981 from augusto2112/fix-remote-mirr 2025-07-12 08:15:13 -07:00
Slava Pestov
355786caa6 Merge pull request #83015 from slavapestov/prepared-overloads-part-3
Prepared overloads, part 3
2025-07-12 08:56:01 -04:00
Slava Pestov
deb80cd985 Merge pull request #83004 from slavapestov/fix-rdar155624135
AST: Change RequirementEnvironment::getRequirementToWitnessThunkSubs() to use contextual types
2025-07-11 21:11:49 -04:00
Slava Pestov
b39d3aee57 Sema: Special-case recording of Bind constraint in PreparedOverload 2025-07-11 19:57:29 -04:00
Slava Pestov
6e212de774 Sema: Lazily build prepared overload when simplifying BindOverload constraint 2025-07-11 19:57:29 -04:00
Augusto Noronha
b6ce889c8d [RemoteMirrors] Fix losing the remote address on StaticMirror
The Offset field of a DynamicRelocation is either an offset or a remote
address, but was being treated only as a remote address on
getDynamicSymbol.
2025-07-11 16:33:19 -07:00
Slava Pestov
44bd5be56f Merge pull request #82976 from slavapestov/prepared-overloads-part-2
Prepared overloads, part 2
2025-07-11 19:10:15 -04:00
Augusto Noronha
d9d7db99dc Merge pull request #82995 from augusto2112/sort-addresses
[RemoteAddress] Handle comparison of addresses in different spaces
2025-07-11 15:34:38 -07:00
Anthony Latsis
06a5670c8f Basic: Untie swift::SourceLoc from llvm::SMLoc
Storing a `llvm::SMLoc` is a superfluous indirection, and getting rid of
it enables us to unconditionally import `SourceLoc` into Swift.
2025-07-11 18:48:42 +01:00
Slava Pestov
03de964154 AST: Change RequirementEnvironment::getRequirementToWitnessThunkSubs() to use contextual types
In the provided test case, the generic signature of the
protocol requirement is

    <Self, T where Self == T.A, T: P2>

The conformance requirement `Self: P1` is derived from `T: P2`
and `Self.A: P1` in P1. So given a substitution map
`{ Self := X, T := T }` that replaces T with a concrete type X
and T with a type parameter T, there are two ways to recover a
substituted conformance for `Self: P1`:

- We can apply the substitution map to Self to get X, and look
  up conformance of X to P1, to get a concrete conformance.

- We can evaluate the conformance path `(T: P2)(Self.A: P1)`,
  to get an abstract conformance.

Both answers are correct, but SILGenModule::emitProtocolWitness()
was assuming it would always get a concrete conformance back.

This was the case until e3c8f423bc,
but then we started returning an abstract conformance. SILGen
would then mangle the protocol witness thunk in a way that was
not sufficiently unique, and as a result, we could miscompile
a program where two witness tables both hit this same scenario.

By using contextual types in the getRequirementToWitnessThunkSubs()
substitution map, we ensure that evaluating the conformance path
against the substitution map produces the same result as performing
the global lookup.

Also, to prevent this from happening again, add a check to SILGen
to guard against emitting two protocol witness thunks with the
same mangled name.

Unfortunately, this is done intentionally as part of some
backward deployment logic for coroutine accessors. There is a
hack to allow duplicate thunks with the same name in this case,
but this should be revisited some day.

Fixes rdar://problem/155624135..
2025-07-11 13:31:35 -04:00
Gabor Horvath
9b1b9b774b [cxx-interop] Types exposed from ObjC modules should be behind a macro
Functions or template instantiations with Obj-C types should always be
behind a macro to make sure the interop header compiles cleanly in C++.

rdar://152836730
2025-07-11 18:22:39 +01:00
Pavel Yaskevich
020596918d Merge pull request #82961 from gottesmm/pr-b3685ba26b885701787f7b6087dc7d9d873aa500
[rbi] Teach SendNonSendable how to more aggressively suppress sending errors around obfuscated Sendable functions
2025-07-11 10:15:21 -07:00
Augusto Noronha
bfaafee378 Merge pull request #82971 from augusto2112/restore-sign-prot-desc
[RemoteMirrors] Restore stripping signed pointer when iterating the
2025-07-11 10:14:56 -07:00
Augusto Noronha
c97dfd6b05 [RemoteAddress] Handle comparison of addresses in different spaces
Sometimes it makes sense to compares addresses from different address
spaces.

rdar://148361743
2025-07-11 10:05:16 -07:00
Allan Shortlidge
302fa00a31 Merge pull request #82962 from tshortli/layout-prespecialization-feature 2025-07-10 21:28:36 -07:00
Dmitrii Galimzianov
7989dbe24e Protocol conformance cache for generic types
This change adds a new type of cache (cache by type descriptor) to the protocol conformance lookup system. This optimization is beneficial for generic types, where the
same conformance can be reused across different instantiations of the generic type.

Key changes:
- Add a `GetOrInsertManyScope` class to `ConcurrentReadableHashMap` for performing
  multiple insertions under a single lock
- Add type descriptor-based caching for protocol conformances
- Add environment variables for controlling and debugging the conformance cache
- Add tests to verify the behavior of the conformance cache
- Fix for https://github.com/swiftlang/swift/issues/82889

The implementation is controlled by the `SWIFT_DEBUG_ENABLE_CACHE_PROTOCOL_CONFORMANCES_BY_TYPE_DESCRIPTOR`
environment variable, which is enabled by default.
2025-07-11 03:54:42 +02:00
Augusto Noronha
16591e4d0e [NFC][RemoteMirrors] Add "template" in front of calls to readRemoteAddress 2025-07-10 17:48:11 -07:00
Slava Pestov
9a8f3baa06 Sema: Add room for a PreparedOverload to BindOverload constraint 2025-07-10 19:53:19 -04:00
Slava Pestov
83f95aeaed Sema: Allocate PreparedOverload in solver arena 2025-07-10 19:53:19 -04:00
Slava Pestov
7916ed982f Sema: Move DeclReferenceType to PreparedOverload.h 2025-07-10 19:53:19 -04:00
Slava Pestov
f7a552385c Sema: PreparedOverload => PreparedOverloadBuilder 2025-07-10 19:53:18 -04:00
Slava Pestov
8527e88423 Sema: Extract prepareOverload() from resolveOverload() 2025-07-10 19:53:15 -04:00
Augusto Noronha
16918e7597 [RemoteMirrors] Restore stripping signed pointer when iterating the
conformance cache

58df5534d2 accidentally removed stripping
this signed pointer.
2025-07-10 15:07:08 -07:00
Allan Shortlidge
96d0450d62 Merge pull request #82940 from tshortli/silgen-custom-availability-domain-query
ClangImporter: Generate and call custom availability domain predicates
2025-07-10 13:16:14 -07:00
Allan Shortlidge
c6dad96492 Make LayoutPrespecialization a baseline feature instead of experimental.
Since LayoutPrespecialization has been enabled by default in all compiler
invocations for quite some time, it doesn't make sense for it to be treated as
experimental feature. Make it a baseline feature and remove all the
checks for it from the compiler.
2025-07-10 11:25:28 -07:00
Michael Gottesman
73e34f020b [rbi] Teach SendNonSendable how to more aggressively suppress sending errors around obfuscated Sendable functions
Specifically the type checker to work around interface types not having
isolation introduces casts into the AST that enrich the AST with isolation
information. Part of that information is Sendable. This means that we can
sometimes lose due to conversions that a function is actually Sendable. To work
around this, we today suppress those errors when they are emitted (post 6.2, we
should just change their classification as being Sendable... but I don't want to
make that change now).

This change just makes the pattern matching for these conversions handle more
cases so that transfernonsendable_closureliterals_isolationinference.swift now
passes.
2025-07-10 11:15:00 -07:00
Michael Gottesman
ea4d0440f4 Revert "[Concurrency] Prevent use of nonisolated(nonsending) and @concurrent on @_inheritActorContext parameters"
This reverts commit e032f33cfb.
2025-07-10 11:15:00 -07:00
Anthony Latsis
8cbf5a26e4 Bridging: Bridge swift::DeclBaseName directly 2025-07-10 17:58:13 +01:00
Anthony Latsis
0e0fbc4160 Bridging: Bridge swift::Identifier directly 2025-07-10 17:58:13 +01:00
Anthony Latsis
f131fece3f [NFC] Bridging: Rework include caveats 2025-07-10 17:58:13 +01:00
Anthony Latsis
b803861257 Bridging: Rename USED_IN_CPP_SOURCE and define it in Basic/SwiftBridging.h 2025-07-10 17:58:13 +01:00
Allan Shortlidge
3d722e1919 ClangImporter: Generate and call custom availability domain predicates.
When importing custom availability domains with dynamic predicates from Clang
modules, synthesize predicate functions for `if #available` queries and call
them when generating SIL.

Resolves rdar://138441312.
2025-07-10 08:15:01 -07:00
Augusto Noronha
21ded5c132 Merge pull request #82638 from augusto2112/change-remote-addr
[NFC][RemoteInspection] Add an opaque AddressSpace field to RemoteAddress
2025-07-10 07:22:10 -07:00
Slava Pestov
3c6b2a20a5 AST: Allocate BuiltinFixedArrayType in the solver arena if needed 2025-07-09 22:16:14 -04:00
Slava Pestov
cdbbe7aa92 Merge pull request #82928 from slavapestov/prepared-overloads
Sema: Opening overloads at the outer decision level, part 1
2025-07-09 22:14:19 -04:00
Doug Gregor
72edcad667 Merge pull request #82900 from DougGregor/region-analysis-conformances-cleanup
[Region isolation] Factor SILIsolationInfo creation into static methods
2025-07-09 15:01:54 -07:00
Augusto Noronha
58df5534d2 [NFC][RemoteInspection] Add an opaque AddressSpace field to RemoteAddress
Add an extra opaque field to AddressSpace, which can be used by clients
of RemoteInspection to distinguish between different address spaces.

LLDB employs an optimization where it reads memory from files instead of
the running process whenever it can to speed up memory reads (these can
be slow when debugging something over a network). To do this, it needs
to keep track whether an address originated from a process or a file. It
currently distinguishes addresses by setting an unused high bit on the
address, but because of pointer authentication this is not a reliable
solution. In order to keep this optimization working, this patch adds an
extra opaque AddressSpace field to RemoteAddress, which LLDB can use on
its own implementation of MemoryReader to distinguish between addresses.

This patch is NFC for the other RemoteInspection clients, as it adds
extra information to RemoteAddress, which is entirely optional and if
unused should not change the behavior of the library.

Although this patch is quite big the changes are largely mechanical,
replacing threading StoredPointer with RemoteAddress.

rdar://148361743
2025-07-09 14:52:42 -07:00
Mike Ash
2edec10efe Merge pull request #82650 from mikeash/memoryreader-dataquery-cache
[Reflection] Cache the various DataQuery values.
2025-07-09 16:03:19 -04:00
Slava Pestov
751edee921 Sema: Rework PreparedOverload to store a list of changes 2025-07-09 15:00:10 -04:00
Slava Pestov
2a0b11a22e Sema: Collect property wrappers in PreparedOverload 2025-07-09 15:00:03 -04:00
Slava Pestov
be6cf92982 Sema: Plumb PreparedOverload through to replaceInferableTypesWithTypeVars() 2025-07-09 15:00:03 -04:00
Slava Pestov
ab72407108 Sema: Collect opened pack expansion types in PreparedOverload 2025-07-09 15:00:02 -04:00
Slava Pestov
c5741e31ed Sema: Stash the existential archetype in PreparedOverload 2025-07-09 15:00:02 -04:00
Slava Pestov
426c7a3fdf Sema: Collect constraints in PreparedOverload 2025-07-09 15:00:02 -04:00
Slava Pestov
543793564e Sema: Record opened type variables in PreparedOverload 2025-07-09 15:00:02 -04:00