Commit Graph

22474 Commits

Author SHA1 Message Date
Michael Gottesman
81b94e27fc Merge pull request #81748 from gottesmm/release/6.2-151802975
[6.2][sema] Change non-sendable -> non-Sendable in diagnostics.
2025-05-27 08:19:54 -07:00
Ian Anderson
44b2c08a5a [6.2][Driver][Frontend] -nostdimport and -nostdlibimport should remove the default framework search paths
-nostdimport and -nostdlibimport only remove the toolchain and usr/lib/swift search paths, and they leave the framework search paths intact. That makes it impossible to get a fully custom SDK environment. Make their behavior match clang's -nostdinc/-nostdlibinc behavior: treat framework and non-framework paths the same. In other words, -nostdinc removes *all* compiler provided search paths, and -nostdlibinc removes *all* SDK search paths.

Rename SkipRuntimeLibraryImportPaths to SkipAllImportPaths, and ExcludeSDKPathsFromRuntimeLibraryImportPaths to SkipSDKImportPaths to reflect their updated behavior.

Move the DarwinImplicitFrameworkSearchPaths handling from SearchPathOptions to CompilerInvocation, where RuntimeLibraryImportPaths is managed. Rename it to just ImplicitFrameworkSearchPaths, and filter for Darwin when it's set up so that all of the clients don't have to do Darwin filtering themselves later.

rdar://150557632
2025-05-23 22:12:45 -07:00
Doug Gregor
e2ee46d724 Merge pull request #81743 from DougGregor/no-unchecked-6.2 2025-05-24 03:58:49 +01:00
Michael Gottesman
b8cf5aeb34 Updates for 6.2.
These were changes that were not updated in the previous commit due to merge conflict
resolution or that the test itself was not in 6.2.
2025-05-23 10:33:58 -07:00
Michael Gottesman
0d519a1acb [sema] Change non-sendable -> non-Sendable in diagnostics.
This matches send non sendable but importantly also makes it clear that we are
talking about something that doesn't conform to the Sendable protocol which is
capitalized.

rdar://151802975
(cherry picked from commit 3ed4059a60)
2025-05-23 10:31:05 -07:00
Pavel Yaskevich
7077ef5ccf Merge pull request #81737 from xedin/rdar-151720646-6.2
[6.2][TypeChecker] Improve diagnostics for access to actor-isolated values…
2025-05-23 10:12:46 -07:00
Doug Gregor
3eb28dcc81 Remove the note that suggests using @unchecked
`@unchecked Sendble` is dangerous, and almost always the wrong thing to
use. Don't have the compiler suggest it.

(cherry picked from commit a922e8e356)
2025-05-23 16:08:59 +01:00
Hamish Knight
6f437241f8 Merge pull request #81721 from hamishknight/macrotrail-6.2
[6.2] [IDE] Better handle macro trailing closures
2025-05-23 10:37:44 +01:00
Pavel Yaskevich
dd95c60c70 [TypeChecker] Improve diagnostics for access to actor-isolated values outside of the actor
Replaces generic `expression is 'async' but is not marked with 'await`
diagnostic with a tailed one for cases where there is an access to an
actor-isolated value outside of its actor without `await` keyword.

This makes the diagnostics for async and sync contexts consistent
and actually identifies a problem instead of simply pointing out
the solution.

Resolves: rdar://151720646
(cherry picked from commit 7a6ba8e8c58c58b3438f31fec06102d02bae81a5)
2025-05-22 23:52:02 -07:00
Pavel Yaskevich
8079f1b12b Merge pull request #81645 from xedin/alwaysInheritActorContext+Task-immediate-6.2
[6.2][Sema/stdlib] SE-0472: implement `@_inheritActorContext(always)` and adopt it in `Task.immediate` APIs
2025-05-22 21:27:26 -07:00
Artem Chikin
8140cbe7b2 Merge pull request #81682 from artemcm/CxxUnderlyingStdLibLookupRemap_62
[6.2 🍒][Dependency Scanning][C++ Interop] Remap lookup of Clang module `CxxStdlib` to `std`
2025-05-22 14:15:52 -07:00
Hamish Knight
26517a1239 [SourceKit] Handle CustomAttrs arguments for placeholder expansion
Introduce a new ASTWalker option for walking CustomAttrs and use it
for the placeholder scanner to ensure we can expand placeholders in
attribute arguments.
2025-05-22 20:17:17 +01:00
Pavel Yaskevich
e12201769d [AST/Sema/SIL] Implement @_inheritActorContext(always)
- Extend `@_inheritActorContext` attribute to support optional `always` modifier.
  The new modifier will make closure context isolated even if the parameter is not
  captured by the closure.
- Implementation `@_inheritActorContext` attribute validation - it could only be
  used on parameter that have `@Sendable` or `sending` and `@isolated(any)` or
  `async` function type (downgraded to a warning until future major Swift mode
  to avoid source compatibility issues).
- Add a new language feature that guards use of `@_inheritActorContext(always)` in swift interface files
- Update `getLoweredLocalCaptures` to add an entry for isolation parameter implicitly captured by `@_inheritActorContext(always)`
- Update serialization code to store `always` modifier

(cherry picked from commit 04d46760bb)
(cherry picked from commit c050e8f75a)
(cherry picked from commit c0aca5384b)
(cherry picked from commit a4f6d710cf)
(cherry picked from commit 6c911f5d42)
(cherry picked from commit 17b8f7ef12)
2025-05-22 11:32:35 -07:00
Steven Wu
559734c6d0 [Caching] Remove CASFS clang module implemenation
Remove the CASFS based clang module implemenation as it is not longer
used.

(cherry picked from commit 3c81c1ca9f)
2025-05-22 11:13:36 -07:00
Steven Wu
4670acf7f9 [Caching] Reduce the number of cas ID passed on frontend commandline
Using IncludeTree::FileList to concat the include tree file systems that
are passed on the command-line. This significantly reduce the
command-line size, and also makes the cache key computation a lot
faster.

rdar://148752988
(cherry picked from commit 201e4faea7)
2025-05-22 11:12:31 -07:00
Andrew Trick
f0ec734c2e Diagnostic message: suppress printing "requires LifetimeDependence"
Adopters of the new Span and MutableSpan types should not encounter information
about an experimental feature when they attempt to use these types in
unsupported ways, such as simply returning them from a function.

Fixes rdar://151788740 (Diagnostic message: suppress printing "requires
'-enable-experimental-feature LifetimeDependence'")

(cherry picked from commit 6cc1a8d880)
2025-05-21 23:00:52 -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
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
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
Mykola Pokhylets
07aedc487c Copy all the options when cloning subscript accessor 2025-05-14 10:11:49 +02: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
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
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
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
Artem Chikin
3c19103270 Downgrade the scanning module variant diagnostic to a warning, for now.
There is concern that this diagnostic may be breaking in some cases on its own.
2025-05-07 10:35:36 -07:00
Anthony Latsis
8a14528728 [6.2] Cherry-pick "Frontend: Obsolete -fixit-all and -emit-fixits-path"
With `ARCMigrate` and `arcmt-test` removed from clang in
https://github.com/llvm/llvm-project/pull/119269 and the new code
migration experience under way (see
https://github.com/swiftlang/swift-evolution/pull/2673), these options
are no longer relevant nor known to be in use. They were introduced
long ago to support fix-it application in Xcode.

For now, turn them into a no-op and emit a obsoletion warning.

(cherry picked from commit 46c394788a84d5932289c71274dd32ea2d61d9dc)
2025-05-07 15:28:17 +01:00