Commit Graph

45907 Commits

Author SHA1 Message Date
Joe Groff
9a8b04fecb Merge pull request #81628 from jckarter/resilient-types-arent-addressable-inside-resilience-domain-6.2
[6.2] SIL: Resilient types don't need to be treated as addressable-for-dependencies inside their resilience domain.
2025-05-21 17:15:38 -07:00
Meghana Gupta
00dcffcd24 [6.2] Fix use-after-free on substituting function type involving conditional ~Escapable with Escapable type 2025-05-21 16:30:02 -07:00
Stephen Canon
85b304220f [6.2] Implement Builtin.select binding llvm select instruction (#81665)
Not used (yet), but needed to implement SIMD.replacing(with:where:)
idiomatically, and probably useful otherwise.

**Explanation:** Makes select available in Swift's builtin module, which
allows implementing concrete SIMD operations more efficiently.
**Risk:** Low. New builtin protected by a feature flag, currently
unused.
**Testing:** New tests added.
**Reviewers:** @eeckstein, @Azoy 
**Main branch PR:** https://github.com/swiftlang/swift/pull/81598
2025-05-21 19:14:33 -04:00
Artem Chikin
93da5b4797 [Dependency Scanning][C++ Interop] Remap lookup of Clang module 'CxxStdlib' to 'std'
Otherwise querying this clang module, e.g. from the corresponding Swift overlay's underlying module import, will fail, since no such module exists.

Resolves rdar://151718115
2025-05-21 09:56:56 -07:00
Ben Barham
8b0901ee4a Merge pull request #81626 from bnbarham/cherry-remove-sk-diag-path
[6.2][SourceKit] Remove diagnostics path calculation
2025-05-20 11:16:43 -07:00
Joe Groff
6aea9660ac SIL: Resilient types don't need to be treated as addressable-for-dependencies inside their resilience domain.
Outside of the resilience domain, they have to be treated as opaque and therefore potentially
addressable-for-dependencies, but inside of the resilience domain, we may take advantage of
knowing the type layout to load indirect parameters out of memory and break the (unnecessary)
dependency on a fixed memory location. Fixes rdar://151268401.

We do still however have problems when the type is actually `@_addressableForDependencies`
inside of its resilience domain (rdar://151500074). I'll fix that in a follow up.
2025-05-19 18:04:17 -07:00
Meghana Gupta
58300798ca Merge pull request #81521 from meg-gupta/disableverificationcp
[6.2] Add a new semantics attribute to disable SIL verification on a function
2025-05-19 18:01:34 -07:00
Ben Barham
03ca9ea0a5 [SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.

Resolves rdar://151500502.

(cherry picked from commit 381684a389)
2025-05-19 14:48:46 -07:00
Michael Gottesman
d3145b2380 [silgen] Begin placing isolation on protocol witness thunks.
This will cause tests today to crash since even though we are placing the
isolation now, to make it easier to read, I left in the old isolation selecting
code. This code uses the witness's isolation instead of the requirement's
isolation which is incorrect since the protocol witness thunk needs to look the
requirement from an ABI perspective since the two must be substitutable. The
crash comes from the ABI verification I added in earlier commits.

(cherry picked from commit ff1cbea576)
2025-05-19 10:33:46 -07:00
Anthony Latsis
e5a10a37d0 Sema: Fix UB in NonisolatedNonsendingByDefault migration diagnosis
The diagnostic can outlive the locally constructed attribute, which was
passed by pointer, if there is an active `DiagnosticTransaction`.

(cherry picked from commit f4e49d5a0a)
2025-05-16 21:25:08 +01:00
Meghana Gupta
06f681777d [6.2] Add a new semantics attribute to disable SIL verification on a function 2025-05-15 14:32:09 -07:00
Pavel Yaskevich
ee3aca2ef3 Merge pull request #81518 from xedin/rdar-148124973-6.2
[6.2][Frontend] Add a way to print features supported by the compiler
2025-05-15 09:46:15 -07:00
Artem Chikin
f8f749b07f Merge pull request #81416 from artemcm/CXXInteropDarwinCycleFix-62 2025-05-15 05:49:39 -07:00
Pavel Yaskevich
61c8e70c66 [Feature] Rename Feature APIs from adoption to migration
(cherry picked from commit 085078dd8a)
2025-05-14 20:28:46 -07:00
Pavel Yaskevich
4e6071c1f8 [Feature] NFC: Rename ADOPTABLE_ with MIGRATABLE_ to match the proposal
(cherry picked from commit 2a479acf9e)
2025-05-14 20:28:46 -07:00
Pavel Yaskevich
8977d80adc [Frontend] Rework -emit-supported-features mode into -emit-supported-arguments
The "featues" part was never actually implemented and Swift Driver
is replying on information about arguments, so instead of removing
this mode, let's scope it down to "arguments" to be deprecated in
the future.

(cherry picked from commit 18703d64d6)
2025-05-14 20:28:46 -07:00
Pavel Yaskevich
e477143d58 [Frontend] Add -print-supported-features option
This is a replacement for `-emit-supported-features` that prints
all of the upcoming/experimental features supported by the compiler
with some additional meta information in JSON format to stdout.

(cherry picked from commit 55bd906906)
2025-05-14 20:28:40 -07:00
Michael Gottesman
e92e9dff0c Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.

(cherry picked from commit 3ff9463957)
2025-05-14 16:07:04 -07:00
Pavel Yaskevich
775a9bc19f Merge pull request #81488 from xedin/rename-some-task-apis-6.2
[6.2][stdlib] SE-0472: Rename Task and*TaskGroup APIs to match the proposal
2025-05-14 14:53:45 -07:00
Mykola Pokhylets
07aedc487c Copy all the options when cloning subscript accessor 2025-05-14 10:11:49 +02:00
Erik Eckstein
21303a5d3d SIL: Make the verifier's ImmutableAddressUseVerifier generally available
Also, make it more tolerant to instructions and builtins, which are not explicitly handled.
This avoids crashes when new instructions are added. We got lucky that this didn't happen so far.
2025-05-14 07:09:32 +02:00
Pavel Yaskevich
2bf00077e4 [stdlib] SE-0472: Rename Task and*TaskGroup APIs to match the proposal
`Task.startSynchronously` -> `Task.immediate`
`*TaskGroup.startTaskSynchronously{UnlessCancelled}` -> `*TaskGroup.addImmediateTask{UnlessCancelled}`

(cherry picked from commit 001eab867d)
2025-05-13 20:11:28 -07:00
Konrad 'ktoso' Malawski
910bc1a1a3 [Concurrency] Improve in order synchronous enqueue of startSynchronously
Previously there was still a sneaky hop which caused ordering issues.
This introduced a specific test startSynchronously_order which checks
that the task enqueues indeed are "immediate" and cleans up how we
handle this.

This also prepares for the being discussed in SE review direction of
this API that it SHOULD be ALLOWED to actually hop and NOT be
synchronous at all IF the isolation is specified on the closure and is
DIFFERENT than the callers dynamic isolation.

This effectively implements "synchronously run right now if dynamically
on the exact isolation as requested by the closure; otherwise enqueue
the task as usual".

resolves rdar://149284186
cc @drexin

(cherry picked from commit a24a28c217)
2025-05-13 20:10:35 -07:00
Artem Chikin
5740ae7bf9 Merge pull request #81452 from artemcm/DepScanFewerClangs-62
[6.2 🍒][Dependency Scanning][Refactor] Reduce the number of ClangImporter instances used by the scanner
2025-05-12 22:09:01 -07:00
Devin Coughlin
4ace71d667 Merge pull request #81409 from hnrklssn/silgen-clang-macros-qual
Prevent silgen for macro expansions with type errors (#81396)
2025-05-12 17:33:48 -07:00
Artem Chikin
fc23c6b460 [Dependency Scanning] Remove 'ClangImporter' instance from dependency scanning worker
Move relevant logic directly into the worker
2025-05-12 10:01:45 -07:00
Doug Gregor
009f868922 Merge pull request #81344 from DougGregor/infer-nonisolated-conformances-from-witnesses-6.2 2025-05-10 08:27:04 -07:00
Hamish Knight
20179aabe9 Merge pull request #81417 from hamishknight/ref-nt-6.2
[6.2] [Frontend] Avoid storing StringRef values in `ModuleAliasMap`
2025-05-10 14:12:08 +01:00
Slava Pestov
8c2ee959bd Merge pull request #81379 from slavapestov/remote-mirrors-meet-packs-6.2
[6.2] RemoteInspection: Support for parameter packs
2025-05-09 22:28:48 -04:00
Doug Gregor
2ea1421aba [SE-0470] Fix synthesized conformances with default main actor isolation
When defaulting to main-actor isolation, types that have synthesized
conformances (e.g., for Equatable, Hashable, Codable) were getting
nonisolated members by default. That would cause compiler errors
because the conformances themselves defaulted to main-actor isolation
when their types were.

Be careful to only mark these members as 'nonisolated' when it makes
sense, and leave them to get the isolation of their enclosing type
when the conformance might have isolation. This ensures that one can
use synthesis of these protocols along with default main-actor mode.

There is a one-off trick here to force the synthesized CodingKeys to
be nonisolated, because the CodingKey protocol requires Sendable.
We'll separately consider whether to generalize this rule.

More of rdar://150691429.
2025-05-09 14:40:21 -07:00
Artem Chikin
7be7ab1e2b [Dependency Scanning][C++Interop] Do not query 'CxxStdlib' Swift overlay for textual modules which were not built with c++interop
When we discover a textual module dependency which is a module which was not originally built from source using C++ interop (specifying '-formal-cxx-interoperability-mode=off'), avoid looking up the C++ standard library Swift overlay for it. This is required for the case of the 'Darwin' module, for example, which includes headers which map to C++ stdlib headers when the compiler is operating in C++ interop mode, but the C++ standard library Swift overlay module itself depends on 'Darwin', which results in a cycle. To resolve such situations, we can rely on the fact that Swift textual interfaces of modules which were not built with C++ interop must be able to build without importing the C++ standard library Swift overlay, so we avoid specifying it as a dependency for such modules.

The primary source module, as well as Swift textual module dependencies which *were* built with C++ interop will continue getting a direct depedency of the 'CxxStdlib' Swift module.

Resolves rdar://150222155
2025-05-09 13:00:59 -07:00
Hamish Knight
54a6d75d15 [Frontend] Avoid storing StringRef values in ModuleAliasMap
Previously we would insert StringRefs that reference the keys in the
map, but that breaks if the invocation ever gets copied. Switch to
`std::string`.

rdar://148130166
2025-05-09 20:46:18 +01:00
Becca Royal-Gordon
e7607e15c0 Merge pull request #81393 from beccadax/abi-let-you-graduate-6.2 2025-05-09 12:28:43 -07:00
Slava Pestov
874449374e RemoteInspection: Support for parameter packs 2025-05-09 14:50:19 -04:00
Slava Pestov
e2f10ed7ca RemoteInspection: Remove 'DidSubstitute' form of TypeRef::subst() 2025-05-09 14:50:16 -04:00
Mike Ash
726e1523f6 Merge pull request #81383 from mikeash/function-cast-ptrauth-6.2
[6.2][Concurrency] Use reinterpret_cast for function_cast when ptrauth is on.
2025-05-09 14:08:19 -04:00
Henrik G. Olsson
0d9707656b Prevent silgen for macro expansions with type errors (#81396)
Due to a bug in how macros on nodes imported from clang are evaluated,
their function body is not always type checked. This forces type
checking before silgen of a macro originating on a node imported from
clang, to prevent crashing in silgen.

rdar://150940383
(cherry picked from commit efd70b1f54)
2025-05-09 10:32:59 -07:00
Nate Cook
c8c035ec32 [6.2][stdlib] Allow a default for optional interpolations (#81360)
Cherry-pick of #80547 for the 6.2 release branch.

---

Explanation: This cherry picks the implementation of SE-0477 to add a
string interpolation method with a `default:` parameter for optional
interpolation values.
Main Branch PR: https://github.com/swiftlang/swift/pull/80547
Risk: Low.
Reviewed By: @stephentyrone 
Resolves: rdar://150865613
Testing: New tests for the string interpolations and fix-its.
2025-05-09 12:10:58 -05:00
Becca Royal-Gordon
e831274256 Make @abi non-experimental
This includes changing the feature name so that compilers with the experimental feature don’t accidentally pick up content that only works in the final version.

Resolves rdar://150065196.
2025-05-08 18:28:34 -07:00
Becca Royal-Gordon
6007e783ad Ban @abi on multi-var PBDs
Per a comment in the review thread that the comma in a multi-variable pattern binding makes it look like the `@abi` attribute has several arguments.
2025-05-08 18:27:58 -07:00
Becca Royal-Gordon
d59d219078 Forbid @_borrowed in @abi
It has indirect effects on the accessors, so it shouldn’t matter, but we can defensively redirect the query to the API counterpart anyway.

This was the last `InferredInABIAttr` attribute, so we can now remove all of the infrastructure involved in supporting attribute inference.
2025-05-08 18:27:58 -07:00
Becca Royal-Gordon
51da65bebd Make inlinability non-ABI for @abi
Inlinability doesn’t affect the mangling except in function specializations, which are applied after the fact and should never mangle in information from an ABI-only decl. That means we can simply ban these from `@abi` instead of inferring them.

Also adds some assertions to help double-check that SIL never tries to directly mangle or retrieve inlinability info from an ABI-only decl.
2025-05-08 18:27:57 -07:00
Becca Royal-Gordon
c8db046cfc Forbid lazy with @abi
It’s not clear how `@abi` would apply to the auxiliary decl used for `lazy`.
2025-05-08 18:27:57 -07:00
Becca Royal-Gordon
31429fc522 [Legacy parser] No freestanding macros in @abi
SwiftSyntaxParser is already doing this, and we already diagnosed it in Sema anyway, so we’re just moving that diagnostic earlier so the ASTGen testing mode is happy. Also adding compiler tests for it.

Macro-related tests are not included in this commit; they require matching swift-syntax changes which are being negotiated.
2025-05-08 18:27:57 -07:00
Becca Royal-Gordon
a103e21d11 Diagnose CustomAttrs as needed in @abi
CustomAttr backs four different features, each of which requires a different behavior in `@abi`:

• Global actors: Permitted (and permitted to vary) since they can affect mangling
• Result builders: Forbidden inside an `@abi` since they have no ABI impact
• Property wrappers: Forbidden both inside an `@abi` and on a decl with an `@abi` since it’s not clear how we would apply `@abi` to the auxiliary decls
• Attached macros: Forbidden inside an `@abi` since an ABI-only decl has no body, accessors, members, peers, extensions, or (currently) conformances

Implement these behaviors (outside of `ABIDeclChecker` since they can’t be described there).

Macro-related tests are not included in this commit; they require matching swift-syntax changes which are being negotiated.
2025-05-08 18:27:57 -07:00
Steven Wu
8e30d7f7c7 Merge pull request #81245 from cachemeifyoucan/eng/PR-145676736-release 2025-05-08 18:21:43 -07:00
Mike Ash
1249899b7e [6.2][Concurrency] Use reinterpret_cast for function_cast when ptrauth is on.
We need to use reinterpret_cast when ptrauth is enabled to ensure that any necessary auth-and-sign operations are performed.

rdar://150747009
(cherry picked from commit 0f2b047155)
2025-05-08 17:15:34 -04:00
Ben Barham
464223e479 Merge pull request #81259 from bnbarham/cherry-merge-modules
[6.2][InterfaceGen] Merge exported modules with the same public name in generated interface
2025-05-08 10:17:17 -07:00
Anthony Latsis
c3b1e97f82 Merge pull request #81358 from AnthonyLatsis/arachnocampa-luminosa-6.2
[6.2] Cherry-pick "Frontend: Obsolete `-fixit-all` and `-emit-fixits-path`"
2025-05-08 13:33:00 +01:00
Artem Chikin
8e1bc70454 Merge pull request #81337 from artemcm/DepScanVariantError-62
[6.2 🍒][Dependency Scanning] Emit a detailed error diagnostic on Clang module variant discovery
2025-05-07 21:12:31 -07:00