Commit Graph

42769 Commits

Author SHA1 Message Date
Kuba (Brecka) Mracek
4a51cfaf27 Merge pull request #76572 from kubamracek/embedded-class-bound-existentials
[embedded] Introduce class-bound existentials into Embedded Swift
2024-09-20 13:58:06 -07:00
Slava Pestov
885d221417 Merge pull request #76585 from slavapestov/small-subst-cleanups-2
More type substitution cleanups
2024-09-20 15:59:04 -04:00
Meghana Gupta
961e6ea104 Merge pull request #76294 from meg-gupta/rewritenext
Rewrite UnsafeRawBufferPointer.Iterator.next
2024-09-20 12:10:39 -07:00
Arnold Schwaighofer
f1a64571fb Merge pull request #76579 from aschwaighofer/async_frame_pointer_all_option
IRGen: Add an option to force emission of an async context pointer on the stack for leaf funclets
2024-09-20 10:43:59 -07:00
Slava Pestov
4bb8f46d6d Merge pull request #76536 from slavapestov/small-subst-cleanups
Tiny optimization and cleanups
2024-09-19 21:36:51 -04:00
Sima Nerush
952ae45b3c Merge pull request #76395 from simanerush/global-actor-cut-off-119628202
[Concurrency] Allow `nonisolated` to prevent global actor inference.
2024-09-19 14:58:15 -07:00
Doug Gregor
6039df3a34 Merge pull request #76565 from DougGregor/remove-if-config
Remove IfConfigDecl from the AST
2024-09-19 13:49:03 -07:00
Arnold Schwaighofer
b49e30c01b IRGen: Add an option to force emission of an async context pointer on the stack for leaf funclets
`-Xfrontend -enable-async-frame-pointer-all`

rdar://135746607
2024-09-19 12:28:57 -07:00
Slava Pestov
a911693c8c AST: PackConformance::getAssociatedType() => getTypeWitness() 2024-09-19 14:18:34 -04:00
Slava Pestov
26241a50f3 AST: Remove DependentMemberType::substBaseType() 2024-09-19 14:18:33 -04:00
Slava Pestov
508dacc3a2 AST: Add ProtocolConformanceRef::getTypeWitness() 2024-09-19 14:18:33 -04:00
Slava Pestov
532e048abb AST: Remove DependentMemberType::substRootParam() 2024-09-19 14:18:32 -04:00
Sima Nerush
7e5a57a07a Guard the changes behind an experimental feature flag. 2024-09-19 10:09:56 -07:00
Sima Nerush
40185cce2a [Concurrency] Allow nonisolated to be used on protocols, extensions, classes, structs, and enums. 2024-09-19 10:09:11 -07:00
Gábor Horváth
4d01253674 Merge pull request #76429 from swiftlang/gaborh/safe-cxx-interop-mode
[cxx-interop] Introduce a safe C++ interop mode
2024-09-19 17:25:28 +01:00
Michael Gottesman
fb281331b3 Merge pull request #76558 from gottesmm/pr-39b63781333d46b16f086a7c192efc67b26255db
[concurrency] Behind the flag UnspecifiedMeansMainActorIsolated, try inferring by default main actor isolation instead of nonisolated for unspecified.
2024-09-19 09:18:33 -07:00
Michael Gottesman
92a3e53b02 Merge pull request #76434 from gottesmm/pr-3e00ab647dbc50beececb8c8cf096921bdf7acd3
[concurrency] Represent a SILFunction without isolation as std::optional<ActorIsolation> instead of ActorIsolation::Unspecified.
2024-09-19 09:17:52 -07:00
Kuba Mracek
6b9a3051e3 [embedded] Introduce class-bound existentials into Embedded Swift
Motivated by need for protocol-based dynamic dispatch, which hasn't been possible in Embedded Swift due to a full ban on existentials. This lifts that restriction but only for class-bound existentials: Class-bound existentials are already (even in desktop Swift) much more lightweight than full existentials, as they don't need type metadata, their containers are typically 2 words only (reference + wtable pointer), don't incur copies (only retains+releases).

Included in this PR:
[x] Non-generic class-bound existentials, executable tests for those.
[x] Extension methods on protocols and using those from a class-bound existential.
[x] RuntimeEffects now differentiate between Existential and ExistentialClassBound.
[x] PerformanceDiagnostics don't flag ExistentialClassBound in Embedded Swift.
[x] WTables are generated in IRGen when needed.

Left for follow-up PRs:
[ ] Generic classes support
2024-09-19 07:49:50 -07:00
Gabor Horvath
929c0ca7d8 [cxx-interop] Introduce a safe C++ interop mode
In this mode all C++ types are imported as unsafe by default. Users
explicitly marking types are escapable or not escapable can make them
imported as safe. In the future, we also want to import unannotated
functions as unsafe and add more logic to infer types that are actually
safe, like agregates of escapable types.
2024-09-19 12:34:07 +01:00
Doug Gregor
5b2520e379 Remove IfConfigDecl from the AST
The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
2024-09-18 20:51:54 -07:00
Doug Gregor
d762dd53f8 Stop parsing into IfConfiDecl nodes in the C++ parser
When parsing #if...#endif regions, parse the active clause directly into
place in the AST without ever producing an IfConfigDecl instance.
2024-09-18 20:51:09 -07:00
Augusto Noronha
0a42612d1c Merge pull request #76533 from DmT021/wp/OpaqueReturnTypeParent-stable-id
[Demangler] Stable parent identifier in OpaqueReturnTypeParent
2024-09-18 14:52:03 -07:00
Michael Gottesman
3843899c19 [concurrency] Behind the flag UnspecifiedMeansMainActorIsolated, try inferring by default main actor isolation instead of nonisolated for unspecified.
Just to play with.
2024-09-18 13:23:23 -07:00
Doug Gregor
3a570e060c Merge pull request #76551 from DougGregor/one-loc-to-file-lookup
Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
2024-09-18 12:55:08 -07:00
Michael Gottesman
a0088327d4 [concurrency] Represent a SILFunction without isolation as std::optional<ActorIsolation> instead of ActorIsolation::Unspecified.
The reason why is that we want to distinguish inbetween SILFunction's that are
marked as unspecified by SILGen and those that are parsed from textual SIL that
do not have any specified isolation. This will make it easier to write nice
FileCheck tests against SILGen output on what is the inferred isolation for
various items.

NFCI.
2024-09-18 11:23:22 -07:00
Doug Gregor
da0c70f301 Merge pull request #76512 from DougGregor/sourcefile-nonopt-buffer
Ensure that SourceFiles always have a backing buffer in the SourceManager
2024-09-18 10:54:52 -07:00
Pavel Yaskevich
43e19358d7 Merge pull request #76458 from xedin/rdar-131347583
[Concurrency] Allow global actor mismatches while overriding `@precon…
2024-09-18 09:16:57 -07:00
Doug Gregor
8febd3fb32 Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
ModuleDecl kept track of all of the source files in the module so that it
could find the source file containing a given location, which relied on
a sorted array all of these source files. SourceManager has its own
similar data structure for a similar query mapping the locations to
buffer IDs.

Replace ModuleDecl's dats structure with a use of the SourceManager's version
with the mapping from buffer IDs to source files.
2024-09-18 07:45:50 -07:00
Gábor Horváth
ffa1014c30 Merge pull request #76311 from swiftlang/gaborh/import-lifetimebound
[cxx-interop] Teach importer to interpret lifetimebound annotations
2024-09-18 15:24:32 +01:00
Egor Zhdan
ad503afc72 Merge pull request #76515 from swiftlang/egorzhdan/scs-reduce-unsafe
[cxx-interop][SwiftCompilerSources] Reduce the number of `SWIFT_IMPORT_UNSAFE` attributes
2024-09-18 12:42:54 +01:00
Gabor Horvath
16e012bb5e [cxx-interop] Teach importer to interpret lifetimebound annotations
The lifetimebound annotations are now imported as lifetime dependencies.
This works for basic cases but there are still some parts missing:
* Support lifeitmebound annotations on constructors
* A way to represent immortal/static lifetimes on the C++ side
2024-09-18 10:51:05 +01:00
Dmitrii Galimzianov
df9ecd9a4c [Demangler] Stable parent identifier in OpaqueReturnTypeParent
`OpaqueReturnTypeParent` node now references the parent with a mangled parent name, rather than a parent pointer. This makes trees obtained from different demanglers (or calls to `Demangler::demangleSymbol`) for the same symbol equal.
2024-09-18 01:14:38 +02:00
Doug Gregor
6f88c228df Maintain a buffer ID -> source file(s) mapping in the source manager
Now that every source file has a buffer ID, introduce the reverse mapping
so clients can find the source file(s) in their module that reference
that buffer ID.
2024-09-17 14:01:58 -07:00
Slava Pestov
ad68d22041 Merge pull request #76518 from slavapestov/fix-issue-76513
Concurrency: Reject nonisolated lazy properties
2024-09-17 15:11:39 -04:00
Hamish Knight
4e32b60e9e Merge pull request #76485 from hamishknight/apply-a-cleanup
[CS] A couple of CSApply cleanups
2024-09-17 18:36:35 +01:00
Slava Pestov
46b4983baf Concurrency: Reject nonisolated lazy properties
We already banned nonisolated property wrappers, and 'lazy' is
conceptually similar, so it makes sense to disallow it also.

Fixes https://github.com/swiftlang/swift/issues/76513.
2024-09-17 11:30:44 -04:00
Slava Pestov
6b57a9f208 Merge pull request #76511 from slavapestov/fix-issue-62061
SIL: Handle ProtocolCompositionType in SubstFunctionTypePatternVisitor
2024-09-17 09:43:00 -04:00
Egor Zhdan
3b540ddbeb [cxx-interop][SwiftCompilerSources] Remove SWIFT_IMPORT_UNSAFE on constructors
These attributes have no effect on C++ constructors.
2024-09-17 13:38:48 +01:00
Egor Zhdan
9aee3ccac0 [cxx-interop][SwiftCompilerSources] Remove incorrect SWIFT_IMPORT_UNSAFE
`swift::Decl` and its inheritors should be treated as foreign reference types in Swift, meaning pointers to them (`Decl*`) should be mapped to Swift classes. This can be done by applying `SWIFT_UNSAFE_REFERENCE` attribute to the `swift::Decl` types. However, at the moment these functions don't seem to be used from Swift, so this change just removes the `SWIFT_IMPORT_UNSAFE` attributes.
2024-09-17 13:23:49 +01:00
Egor Zhdan
9ee34df6df [cxx-interop][SwiftCompilerSources] Remove redundant SWIFT_IMPORT_UNSAFE
`OptionalInt` is not an unsafe type in Swift, so the attribute has no effect.
2024-09-17 13:15:40 +01:00
Egor Zhdan
0efa7f90ef [cxx-interop][SwiftCompilerSources] Do not use SWIFT_IMPORT_UNSAFE with SILDebugLocation
`SWIFT_IMPORT_UNSAFE` is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

`SILDebugLocation` is better described as a self-contained Swift type.

Similar to 35263ef9.
2024-09-17 13:07:57 +01:00
Hamish Knight
1cc00e3676 [CS] NFC: Remove SolutionApplicationToFunctionResult
This is now no longer needed.
2024-09-17 12:35:11 +01:00
Hamish Knight
930dc18eb7 [CS] Avoid delaying application for multi-statement closures
We ought to be able to apply the solution to them
immediately now.
2024-09-17 12:35:11 +01:00
Hamish Knight
f0151c1d21 [CS] Delay type-checking of local decls
Delay `typeCheckDecl` for local decls until the
end of CSApply. This replaces the existing logic
for delaying type-checking for local functions.
2024-09-17 12:35:10 +01:00
Hamish Knight
d99d881af5 [CS] NFC: Factor out base class SyntacticElementTargetRewriter
Pass this instead of a function for rewriting
targets.
2024-09-17 12:35:10 +01:00
Saehej Kang
6c92f3fe1c [Diag]: Result builder misplacement error message mentions subscript 2024-09-17 02:45:07 -07:00
eeckstein
85ecc954b8 Merge pull request #76448 from eeckstein/fix-static-init-cloner
StaticInitCloner: skip begin_access instructions when cloning the initial value of a global
2024-09-17 07:54:58 +02:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
Doug Gregor
4d920f01d3 Merge pull request #76503 from DougGregor/unused-ifconfig-walk
Remove unused shouldWalkInactiveConfigRegion
2024-09-16 20:22:47 -07:00
Slava Pestov
5147adcca5 SIL: Handle ProtocolCompositionType in SubstFunctionTypePatternVisitor
Fixes https://github.com/swiftlang/swift/issues/62061.
2024-09-16 21:20:55 -04:00