Commit Graph

20496 Commits

Author SHA1 Message Date
Slava Pestov
5e30f6a4c3 AST: Optimize ModuleDecl::isImportedAsWeakLinked() 2024-07-12 15:53:58 -04:00
Allan Shortlidge
373a3fe7de Merge pull request #75185 from tshortli/revert-aeic-diagnose-unavailable-code-reached
SILGen/stdlib: Remove `_diagnoseUnavailableCodeReached_aeic()`
2024-07-12 09:22:11 -07:00
Saleem Abdulrasool
7cc7e2bd3a Merge pull request #72352 from compnerd/sysroot
Driver: introduce `-sysroot` option for non-Darwin targets
2024-07-12 08:08:59 -07:00
Holly Borla
85b66d1dc2 [ConformanceLookup] Always prefer unavailable Sendable conformances from the
defining module, and diagnose redundant Sendable conformances.

We still allow re-stating inherited unchecked Sendable conformances in
subclasses because inherited Sendable conformances are surprising when
they opt out of static checking. Otherwise, warning on redundant Sendable
conformances nudges programmers toward cleaning up unnecessary retroactive
Sendable conformances over time as libraries incrementally add the
conformances directly.
2024-07-11 20:33:24 -07:00
Pavel Yaskevich
6925940b37 [Sema] Improve diagnostic when @usableFromInline is applied to a declaration without a name (i.e. accessor/init) 2024-07-11 17:12:57 -07:00
Allan Shortlidge
14200e412c SILGen/stdlib: Remove _diagnoseUnavailableCodeReached_aeic().
It should no longer be necessary to provide an `@_alwaysEmitIntoClient` version
of `_diagnoseUnavailableCodeReached()`. This workaround was originally added to
provide compatibility with projects that were misconfigured to compile against
a newer stdlib but link against an older one.

Resolves rdar://119892482.
2024-07-11 14:53:03 -07:00
Ellie Shin
cb776089cb Merge pull request #75154 from swiftlang/elsh/drop-exp-prefix
Drop experimental prefixes from PackageCMO flags.
2024-07-11 12:12:29 -07:00
Pavel Yaskevich
e4cd1d7acd Merge pull request #75062 from xedin/rdar-122193606
[Concurrency] Allow sendability mismatches while overriding `@preconcurrency` properties in Swift 5 mode
2024-07-11 11:18:53 -07:00
Allan Shortlidge
5d6f6947ed Merge pull request #75158 from tshortli/member-import-visibility-package
AST: Add a `IgnoreMissingImports` option to name lookup
2024-07-11 11:07:39 -07:00
Allan Shortlidge
d002da0ef2 AST: Add a IgnoreMissingImports option to name lookup.
Control enforcement of member import visibility requirements via a new option,
instead of piggy-backing on the existing IgnoreAccessControl option. Adopt the
option when doing fallback lookups for unviable members so that the compiler
can diagnose the reason that a member is inaccessible more reliably.
Previously, with MemberImportVisibility enabled decls with the package access
level could be mis-diagnosed as inaccessible due to their access level when
really they were inaccessible due to a missing import.

Resolves rdar://131501862.
2024-07-10 22:57:15 -07:00
Andrew Trick
12acde2215 Merge pull request #75096 from meg-gupta/lifetimedeparg
Add support for lifetime dependence in parameter position
2024-07-10 22:56:23 -07:00
Kavon Farvardin
bbc02a5544 Merge pull request #75141 from kavon/invertible-conformance-same-sourcefile
NCGenerics: enforce same-source conformance rule
2024-07-10 17:50:13 -07:00
Slava Pestov
d1847ffde7 Merge pull request #75068 from slavapestov/simplify-sub-map
Simplify and optimize SubstitutionMap
2024-07-10 20:45:56 -04:00
Ellie Shin
18681c43fb Drop experimental prefixes from PackageCMO flags.
Deprecate experimental- flags with prompts to use the proper flags.

rdar://131498517
2024-07-10 16:19:16 -07:00
Shubham Sandeep Rastogi
d443fdd501 Merge pull request #74202 from rastogishubham/MCCASReplay
Add replay support for MCCAS in Swift.
2024-07-10 15:21:51 -07:00
Meghana Gupta
076d70acbb Update getLifetimeDependenceInfo to getLifetimeDependencies in CSSimplify 2024-07-10 14:48:34 -07:00
Meghana Gupta
fecd2b452d Don't mangle lifetime dependencies in older runtimes 2024-07-10 14:48:34 -07:00
Meghana Gupta
2b28da6dd7 Update ASTPrinting of lifetime dependence 2024-07-10 14:48:34 -07:00
Meghana Gupta
815d7a67f5 Replace hasLifetimeDependenceInfo -> hasLifetimeDependencies 2024-07-10 14:48:34 -07:00
Meghana Gupta
7d2ff43fe3 Update mangling to support lifetime dependence in parameter position 2024-07-10 14:20:03 -07:00
Meghana Gupta
154989463b Add support for lifetime dependence in parameter position 2024-07-10 14:20:03 -07:00
Meghana Gupta
8137aed238 Rename LifetimeDependentReturnTypeRepr -> LifetimeDependentTypeRepr 2024-07-10 14:20:03 -07:00
Meghana Gupta
4993f4bf22 Merge pull request #74956 from meg-gupta/lifetimedepfunctiontype
Add some diagnostics related to lifetime dependence and function types
2024-07-10 14:19:05 -07:00
Kavon Farvardin
233742a565 NCGenerics: enforce same-source conformance rule
SE-427 says the conformance to Copyable must appear in the same source
file as the nominal type.

resolves rdar://131486561
2024-07-10 14:02:10 -07:00
Doug Gregor
2a8b3fcf95 Merge pull request #75093 from DougGregor/unsafe-inherit-executor-vs-pound-isolation
Ensure that a `@_unsafeInheritExecutor` function does not depend on `#isolation`
2024-07-10 11:05:37 -07:00
Saleem Abdulrasool
c8bec5b12f Driver: introduce -sysroot option for non-Darwin targets
This introduces a secondary flag `-sysroot` for the non-Darwin targets,
primarily Unicies. The intention here is to support a split `-sdk`,
`-sysroot` model where the `-sdk` parameter provides the Swift "SDK"
which augments the native platform's C sysroot which is indicated as
`-sysroot`. For the case of Android, this would allow us to provide a
path to the NDK sysroot and the Swift SDK allowing us to cross-compile
Android binaries from Windows.
2024-07-10 11:03:18 -07:00
Slava Pestov
eca5a1c342 AST: Optimize getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Slava Pestov
26fffae30a AST: Simplify SubstitutionMap representation
There was a bunch of logic to lazily populate replacement types
corresponding to reducible generic parameters. This didn't seem
to have a clear purpose so let's remove it.
2024-07-10 13:28:26 -04:00
Slava Pestov
977b444eb3 AST: Add a new overload of getContextSubstitutionMap() 2024-07-10 13:28:26 -04:00
Shubham Sandeep Rastogi
8dabf58993 Add support for MCCAS in replay logic for swift
This patch adds support for MCCAS when a cache hit is encountered when
trying to replay a compilation, and uses the MCCAS serialization code
to materialize the object file that is the main output of the
compilation.
2024-07-10 10:19:10 -07:00
Pavel Yaskevich
19f59ce0c1 Merge pull request #75087 from xedin/rdar-130776220-limited
[Concurrency] Fix disallowed override isolation to carry `@preconcurr…
2024-07-10 01:02:40 -07:00
Allan Shortlidge
cf2c6ff1bb Merge pull request #75094 from tshortli/baseline-more-features 2024-07-09 23:11:45 -07:00
Steven Wu
9318937498 Merge pull request #75082 from cachemeifyoucan/eng/PR-131214106
[Macro] Fix bugs in macro dependency scanning
2024-07-09 15:33:01 -07:00
Allan Shortlidge
8093783e21 AST: Promote ExtensionMacroAttr feature to baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
6b9b7bcd83 AST: Promote PrimaryAssociatedTypes2 feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
b5acc6b07d AST: Promote AsyncSequenceFailure feature to the baseline. 2024-07-09 14:28:28 -07:00
Pavel Yaskevich
65fb35c3bd Revert "Convert ActorIsolationRequest to use split caching"
There are a few spots in `ActorIsolationRequest` that produce
`unspecified` isolation with `preconcurrency` bit set and diagnostics
rely on that to make downgrade decisions in Swift 5 mode.

This reverts commit 0097ef68a6.
2024-07-09 13:34:25 -07:00
Steven Wu
da10a02231 [Macro] Fix bugs in macro dependency scanning
Fix few issues from previous implementation from explicit module build
with macros and accurate macro dependency scanning in
https://github.com/swiftlang/swift/pull/73421.

First, there is a crash when propagating the macro dependencies. It
turns out that the current macro plugin implementation doesn't need the
downstream users to know about the plugin search path from the upstream
dependencies.

Secondly, fix a bug that the swiftinterface that has macro usage won't
build because the build command doesn't inherit the plugin search path
option.

Finally, add JSON output for macro dependencies so it is easier to
debug the macro dependencies.

rdar://131214106
2024-07-09 10:37:27 -07:00
Meghana Gupta
bbd54ae8a8 Ban annotating function type with lifetime dependence 2024-07-09 09:13:14 -07:00
Doug Gregor
45d4d975cd Deprecate @_unsafeInheritExecutor and remove it from Swift 6 2024-07-08 23:35:34 -07:00
Doug Gregor
5f049b63ef Diagnose attempts to use #isolation within an @_unsafeInheritExecutor function
An `@_unsafeInheritExecutor` function is unsafe because it doesn't
really "inherit" the executor, it just avoids immediately hopping off
the executor. That means that using `#isolation` within such a
function is fundamentally broken. Ban the use of `#isolation` within
such a function, providing a Fix-It that removes the
`@_unsafeInheritExecutor` attribute and adds a defaulted parameter

    isolation: (any Actor)? = #isolation

instead. That's the real, safe pattern that want going forward.

We did say it was unsafe, after all. Part of rdar://131151376.
2024-07-08 23:34:28 -07:00
Allan Shortlidge
7e4425c97e Merge pull request #75090 from tshortli/no-more-ncg-condfails
AST: Remove `NoncopyableGenerics` feature suppression
2024-07-08 23:03:40 -07:00
Allan Shortlidge
9e5a9b963f AST: Remove NoncopyableGenerics feature suppression.
It is no longer necessary to produce `.swiftinterface` files the support older
compilers that lack support for the NoncopyableGenerics feature. Cleaning this
up makes the stdlib `.swiftinterface` far more readable.
2024-07-08 17:44:24 -07:00
Steven Wu
30737eb396 [Caching] Support swift style diagnostics for swift caching
Add support for swift style diagnostics for swift caching. This includes
pre-populate the GeneratedSourceInfo with macro name so it doesn't need
to infer from an ASTNode, which the caching mechanism cannot preserve.

Still leave the default diagnostic style to LLVM style because replaying
swift style diagnostics is still very slow and including parsing source
file using swift-syntax.

rdar://128615572
2024-07-08 16:15:44 -07:00
Steven Wu
8ff3b05766 [NFC] Factor out DiagnosticBridge between swift-syntax
Refactor out the code that handles printing diagnostics from
swift-syntax.
2024-07-08 16:15:44 -07:00
Michael Gottesman
1160951585 Merge pull request #75069 from gottesmm/pr-6b7256344bb1a1ceb9d13dae6d52db0d356b46a3
[region-isolation] Treat async let as a isolation inference boundary closure and fix diagnostics due to change.
2024-07-08 14:48:27 -07:00
Michael Gottesman
03b26fd65b [region-isolation] Treat async let as a isolation inference boundary closure and fix diagnostics due to change.
Otherwise, we will assume that an async let autoclosure infers isolation from
its DeclContext... which we do not want. An async let autoclosure should always
be nonisolated + sending.

The diagnostic change that I mentioned in the header is that we were emitting
unfortunate "sending task or actor isolated could result in races" error. I
eliminated this by adding a new diagnostic for transfer non transferrable errors
happening in autoclosures. So now we emit this:

```swift
  func asyncLetInferAsNonIsolated<T : Actor>(
    isolation actor: isolated T
  ) async throws {
    async let subTask: Void = {
      await useValueAsyncNoReturnWithInstance(self, actor)
      // expected-warning @-1:47 {{sending 'self' risks causing data races}}
      // expected-note @-2 {{sending 'actor'-isolated 'self' into async let risks causing data races between nonisolated and 'actor'-isolated uses}}
    }()
    await subTask
```

I also noticed that we did not have enough test cases for autoclosures in
general so I also added a bunch of tests just so we can see what the current
behavior is. I think there are a few issues therein (I believe some may have
been reported due to '??').

rdar://130151318
2024-07-08 11:22:29 -07:00
Michael Gottesman
20acc503c2 Fix three typos in comments. NFC. 2024-07-08 11:01:44 -07:00
Kavon Farvardin
591891f7d4 Merge pull request #74918 from kavon/availability-ncgenerics
NCGenerics: add availability checking
2024-07-08 09:00:43 -07:00
Erik Eckstein
1a308ef2fe PerformanceDiagnostic: give an error if a generic non-copyable value with a deinit is captured by an escaping closure.
Otherwise IRGen would crash.
It needs a bit of work to support alloc_box of generic non-copyable structs/enums with deinit, because we need to specialize the deinit functions, though they are not explicitly referenced in SIL.
Until this is supported, give an error in such cases.

Fixes a compiler crash in IRGen
rdar://130283111
2024-07-08 10:05:19 +02:00