Commit Graph

1915 Commits

Author SHA1 Message Date
Doug Gregor
8b514ec029 Merge pull request #70902 from DougGregor/isolation-macro
Implement `#isolation` macro to produce the isolation of the current context
2024-01-16 14:27:00 -08:00
Doug Gregor
255009dddb Implement #isolation macro to produce the isolation of the current context
Introduce a new expression macro that produces an value of type
`(any AnyActor)?` that describes the current actor isolation. This
isolation will be `nil` in non-isolated code, and refer to either the
actor instance of shared global actor in other cases.

This is currently behind the experimental feature flag
OptionalIsolatedParameters.
2024-01-16 14:25:51 -08:00
Pavel Yaskevich
3a61394ae3 Merge pull request #70693 from xedin/rdar-104246144
[ClangImporter] Augment type import to support SwiftAttr in type contexts
2024-01-16 12:01:55 -08:00
Pavel Yaskevich
a26af37ecc [Serialization] Add @preconcurrency bit to normal conformance descriptor 2024-01-16 11:51:49 -08:00
Pavel Yaskevich
233d279a5c [AST] Support @preconcurrency attribute on test/extension inheritance entries 2024-01-16 10:30:58 -08:00
Pavel Yaskevich
1e1f0a54ae [Serialization] Implementation serialization of clang::SwiftAttrAttr
This is an attribute that is attached to `AttributedType` to support
concurrency annotations in type context.
2024-01-12 11:32:06 -08:00
Allan Shortlidge
432e4dccab Serialization: Remove Swift3Inferred field from @objc attr. 2024-01-11 15:41:11 -08:00
Allan Shortlidge
e5c6bb649c Remove support for Swift 3 @objc inference.
Obsolete the `-enable-swift3-objc-inference` option and related options by
removing support for inferring `@objc` attributes using Swift 3 rules.
Automated migration from Swift 3 has not been supported by the compiler for
many years.
2024-01-11 15:40:04 -08:00
Alejandro Alonso
e37ecac163 Merge pull request #68857 from Azoy/atomics
[stdlib] Atomics
2024-01-10 12:03:08 -08:00
Alejandro Alonso
90f5a0a7ba Record new SIL block records 2024-01-09 22:42:16 -08:00
Michael Gottesman
1764bd2479 [sil] Change SILParameterInfo/SILResultInfo's differentiability parameter to use an OptionSet so we can add other options.
I am doing this in preparation for adding options to SILParameterInfo/
SILResultInfo that state that a parameter/result is transferring. Even though I
could have just introduced a new bit here, I instead streamlined the interface
of SILParameterInfo/SILResultInfo to use an OptionSet instead of individual bits
to make it easier to add new flags here. The reason why it is easier is that
along API (e.x.: function argument) boundaries one does not have to marshal each
field or pass each field. Instead one can just pass the whole OptionSet as an
opaque thing. Using this I was able to change serialization/deserialization of
SILParameterInfo/SILResultInfo so that one does not need to update them if one
adds new fields!

The reason why I am doing this for both SILParameterInfo/SILResultInfo in the
same commit is because they share code in the demangler that I did not want to
have to duplicate in an intervening commit. By changing them both at the same
type, I didn't have to change anything without an actual need to.

I am doing this in a separate commit from adding transferring support so I can
validate correctness using the tests for the options already supported
(currently only differentiability).
2024-01-02 15:03:05 -08:00
Meghana Gupta
d3e921dc47 Make _resultDependsOn available on SILFunctionArgument 2023-12-29 01:57:19 -08:00
Kavon Farvardin
a6b27d0f85 [NCGenerics] fix serialization of PCT
resolves rdar://118947007
2023-12-12 16:40:13 -08:00
Doug Gregor
7a3e3aea15 Merge pull request #70353 from DougGregor/error-union-type
[Typed throws] Add an ErrorUnion type to the type system
2023-12-11 22:04:10 -08:00
Allan Shortlidge
953489d3d6 Serialization: Resolve macro conformances during serialization.
This ensures that conformances get serialized correctly when
`-experimental-lazy-typecheck` is specified.

Resolves rdar://119463830.
2023-12-10 10:06:54 -08:00
Dario Rexin
36dd2c9450 [SilOpt] Add new layout type _TrivialStride and add pre-specialization suppport for it (#70308)
rdar://119329771

This layout allows adding pre-specializations for trivial types that have a different size, but the same stride. This is especially useful for collections, where the stride is the important factor.
2023-12-09 08:13:50 -08:00
Doug Gregor
b080b5f3d8 [Typed throws] An ErrorUnion type to the type system
The errorUnion type operation specifies how thrown error types are
combined when multiple errors are thrown in the same context. When
thrown error types can have type variables in them, we sometimes cannot
resolve the errorUnion until the type variables have substitutions. In
such cases, we need to persist the result of errorUnion in the
constraint solver.

Introduce the ErrorUnionType to do exactly that, and update the core
errorUnion operation to produce an ErrorUnionType when needed. At
present, this code is inert, because any errorUnion operation today
involves only concrete types. However, inference of thrown errors in
closures will introduce type variables, and depend on this.
2023-12-08 22:30:37 -08:00
Dario Rexin
df35f3327d [SilOpt] Add new layout _BridgeObject and add pre-specialization support for it (#70239)
rdar://119048001
2023-12-08 14:34:16 -08:00
Kavon Farvardin
63b3e7624d [NCGenerics] fold InverseType into PCT
We already need to track the inverses separate from the members in a
ProtocolCompositionType, since inverses aren't real types. Thus, the
only purpose being served by InverseType is to be eliminated by
RequirementLowering when it appears in a conformance requirement.

Instead, we introduce separate type InverseRequirement just to keep
track of which inverses we encounter to facilitate cancelling-out
defaults and ensuring that the inverses are respected after running
the RequirementMachine.
2023-12-07 22:14:23 -08:00
Meghana Gupta
fd588ab509 Remove SelfAccessKind::ResultDependsOnSelf 2023-11-29 12:11:57 -08:00
Doug Gregor
84b9b94387 Macro role metaprogramming for serialization 2023-11-25 10:20:33 -08:00
Meghana Gupta
5658deae27 Add initial support for _resultDependsOnSelf
This is used to establish lifetime dependence between self and the result.

Add under NonEscapableTypes experimental feature
2023-11-08 01:48:59 -08:00
Alexis Laferrière
f2d1627656 [Serialization] Fix deserializing opaque types for computed properties and subscripts
A client shouldn't know about the underlying type of an opaque type
unless it can see the body of the naming decl. Attempting to read it can
lead to accessing a hidden dependency and a compiler crash.

This was protected by a check specific to function decls but var decls
and subscripts were not handled. To support them we have to move this
logic to the writer side where we have access to the full
AbstractStorageDecl and write in the swifmodule whether the underlying
type should be visible outside of the module.

rdar://117607906
2023-11-01 16:04:10 -07:00
Kavon Farvardin
29acda5136 Merge pull request #69406 from kavon/noncopyable-generics-pt2
[NoncopyableGenerics] handle `~Copyable` in `where`, `some`, and compositions.
2023-10-28 22:36:22 -07:00
Allan Shortlidge
66abd325f9 Merge pull request #69456 from tshortli/serialization-lazy-typecheck-custom-attr
Serialization: Resolve type of CustomAttr before serializing
2023-10-27 14:29:19 -07:00
Meghana Gupta
3c244c30b0 Merge pull request #69436 from apple/revert-69416-revert-69254-dwarf-version
Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable.""
2023-10-27 13:38:48 -07:00
Allan Shortlidge
33edb6642d Serialization: Resolve type of CustomAttr before serializing.
This fixing a crash during serialization when lazy typechecking is enabled.

Resolves rdar://117442955
2023-10-26 22:46:58 -07:00
Sophia Poirier
4c9a726183 nonisolated(unsafe) to opt out of strict concurrency static checking for global variables 2023-10-26 16:22:28 -07:00
Adrian Prantl
5d978b44ca Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable."" 2023-10-26 12:29:18 -07:00
Adrian Prantl
2a32ca5944 Revert "Make the DWARF version emitted by the Swift compiler configurable." 2023-10-25 13:28:28 -07:00
Adrian Prantl
d19fe381fa Use LLVM definitions for Swift section names (NFC) 2023-10-24 10:58:40 -07:00
Yuta Saito
4f0e3bf3ea Merge pull request #69207 from kateinoigakukun/yt/cdecl-without-body
Introduce `@extern(c)` to declare C function without Clang module
2023-10-23 12:48:12 -07:00
Kavon Farvardin
66712ce6e0 [Sema] introduce InverseType
This type will become the corresponding type that is resolved for an
`InverseTypeRepr`. This kind of type is not expected to appear past type
 checking (currently, not even past requirement lowering!).
2023-10-23 10:37:22 -07:00
Yuta Saito
b27fd9a616 [c-interop] Add @_extern(c) attribute to declare C function in Swift 2023-10-20 15:34:08 +00:00
Evan Wilde
312bd47f4c Merge remote-tracking branch 'main' into 'rebranch' 2023-10-16 23:00:12 -07:00
Mishal Shah
3594f8ecaf Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
	test/IRGen/opaque-pointer-llvm.swift
2023-10-15 23:49:40 -07:00
Becca Royal-Gordon
5c8bcfdf52 [NFC] Correct AFD::needsNewVTableEntry()
Serialization depended on a longstanding bug in NeedsNewVTableEntryRequest: For a member of a non-class, it always returned `true`, not `false`. It turns out this was because serialization was conflating the concepts of vtable entries and witness table entries, so it needed NeedsNewVTableEntryRequest to return true for members of protocols. Untangle this logic so that NeedsNewVTableEntryRequest can be given the logical behavior.
2023-10-13 14:33:44 -07:00
Artem Chikin
6a699b61b1 Merge pull request #69109 from artemcm/EBM_BridgingHeader_Fix
[Explicit Module Builds] Restore prior behavior of consuming `.h` dependencies of binary module dependencies directly, instead of attempting to load their PCH
2023-10-13 09:04:37 -07:00
swift-ci
d432ad3f51 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 10:54:41 -07:00
Allan Shortlidge
229398c01d Merge pull request #69141 from tshortli/silgen-lazy-typecheck
SILGen: Introduce option to skip non-exportable declarations
2023-10-12 10:49:06 -07:00
swift-ci
13417f9331 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 09:35:04 -07:00
Yuta Saito
051bf4dd43 Merge pull request #69107 from kateinoigakukun/yt/extern-wasm-sym
[wasm] Add @_extern(wasm) attribute support
2023-10-12 09:29:13 -07:00
Artem Chikin
75ee48ca77 [Dependency Scanning] Do now write out bridging header dependencies of binary modules unless in CAS mode
We only record these dependencies in CAS mode, because we require explicit PCH tasks to be produced for imported header of binary module dependencies. In the meantime, in non-CAS mode loading clients will consume the `.h` files encoded in the `.swiftmodules` directly.

Followup changes to SwiftDriver will enable explicit PCH compilation of such dependenceis, but for the time being restore prior behavior for non-CAS explicit module builds.

Resolves rdar://116006619
2023-10-12 06:24:11 -07:00
Allan Shortlidge
a7daf13bf6 AST: Introduce and adopt Decl::isExposedToClients().
This method is a more ergonomic utility wrapping DeclExportabilityVisitor.
2023-10-11 22:41:31 -07:00
swift-ci
bfc9d85449 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-11 18:14:16 -07:00
Slava Pestov
a3fa3bf110 Merge pull request #69038 from slavapestov/clean-up-associated-conformances
Preparation for lazily populating associated conformances
2023-10-11 20:58:27 -04:00
Artem Chikin
3bb5424296 [Serialization] Serialize source '.h' path when an explicit '.pch' bridging header is provided
In explicit module builds, bridging header is passed directly as a '.pch' input.

Loading clients may not be able to directly import this PCH because it was built against mis-matched dependencies with a different context hash. So instead they should directly injest the '.h' depndency and build it against their own set of dependencies.
2023-10-11 13:15:12 -07:00
Slava Pestov
793c7a18e2 Serialization: Use forEachAssociatedConformance() 2023-10-11 15:04:09 -04:00
swift-ci
d967b1878a Merge remote-tracking branch 'origin/main' into rebranch 2023-10-10 20:08:25 -07:00
Allan Shortlidge
f131c8a3f5 Frontend: Introduce -experimental-skip-non-exportable-decls.
Rename -experimental-serialize-external-decls only to
-experimental-skip-non-exportable-decls in preparation for the flag being used
to influence more than just serialization.

Resolves rdar://116771543
2023-10-10 16:07:04 -07:00