Commit Graph

22435 Commits

Author SHA1 Message Date
Hamish Knight
f4bea5f7c0 Merge pull request #77203 from hamishknight/wrapping-paper-sema
[Sema] Avoid relying on ParenType in a couple of places
2024-10-26 21:25:17 +01:00
Pavel Yaskevich
ab4d8f61eb [Serialization] Add -swift-compiler-version option to swiftmodules 2024-10-25 09:53:40 -07:00
Erik Eckstein
ed67e36ce5 bridging: reduce #ifdef USED_IN_CPP_SOURCE in bridging headers
Especially avoid any constructors in `#ifdef USED_IN_CPP_SOURCE` blocks, because this breaks Windows ARM64.
2024-10-25 09:47:56 +02:00
Allan Shortlidge
4c6b8a1d97 AST: Introduce AvailabilityInference::availableRangeAndAttr().
Also, clean up some documentation.
2024-10-24 20:06:35 -07:00
Pavel Yaskevich
39fb638516 [Frontend/AST] Make it possible to determine Swift compiler version used to build a ModuleDecl 2024-10-24 17:06:15 -07:00
Ben Barham
746517c9f2 Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `test/IRGen/has_symbol.swift` test updates in rebranch. The new test
    will fail, will fix in the next commit.
2024-10-24 14:20:17 -07:00
Slava Pestov
9d85221ae5 Parse: Save and restore InFreestandingMacroArgument when delayed parsing
Closures appearing in freestanding macro arguments don't have
discriminators assigned, since we don't actually emit them.

Similarly we skip recording opaque return types that appear in macro
arguments, since they don't get emitted.

However this logic didn't take delayed parsing into account, which must
save and restore the InFreestandingMacroArgument bit correctly.

As a result, if the freestanding macro argument contained a closure
which contained a local function with a declaration that has an
opaque return type, we would crash in serialization from attempting
to mangle an opaque return type nested inside of a closure without a
discriminator.

Fixes rdar://135445004
2024-10-24 17:19:50 -04:00
Slava Pestov
5190d98e1b Merge pull request #77178 from slavapestov/misc-solver-cleanups
Miscellaneous solver cleanups
2024-10-24 16:52:01 -04:00
Hamish Knight
3c8921aa69 [Sema] Avoid relying on ParenType in space engine
Refactor `decomposeDisjuncts` to avoid relying on
the modeling of single unlabeled associated values
as ParenTypes.
2024-10-24 15:29:48 +01:00
nate-chandler
b7fd4e140d Merge pull request #77179 from nate-chandler/general-coro/20241017/1
[CoroutineAccessors] Permit read requirement.
2024-10-23 11:17:43 -07:00
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Jakub Florek
2cc00889bd Switch to integer division inaddPaddingUpTo. Rename magic constants in LoggingASTScopeDeclConsumer. Format BridgedConsumedLookupResult. 2024-10-23 12:27:15 +02:00
Nate Chandler
f797e19a29 [Parse] Updated protocol diagnostic to allow read.
With the `CoroutineAccessors` feature, `read` is allowed along with
`get` and `set`; alter the diagnostic that's issued when a disallowed
introducer is listed in the requirement list to indicate that `read` is
one of those which are valid, but only when the feature is enabled.
2024-10-22 18:03:03 -07:00
Slava Pestov
5e1e18424b AST: Clean up ExistentialLayout for ParameterizedProtocolType 2024-10-22 20:14:44 -04:00
swift-ci
9a7afe7e79 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-22 16:37:30 -07:00
Allan Shortlidge
bc30ecc438 Merge pull request #77166 from tshortli/copy-constructor-warning
AST: Fix a `-Wdeprecated-copy-with-user-provided-copy` warning
2024-10-22 16:24:21 -07:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
swift-ci
3d969906c5 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-22 13:14:35 -07:00
Allan Shortlidge
748dde5bfa AST: Fix a -Wdeprecated-copy-with-user-provided-copy warning. 2024-10-22 09:31:55 -07:00
Allan Shortlidge
536e666aba Sema: Introduce TypeChecker::availabilityAtLocation().
Implement a query that returns the `AvailabilityContext` for a given
`SourceLoc` and `DeclContext`. Re-implement the existing type checker query
that just returns an `AvailabilityRange` on top of the new query.
2024-10-22 08:39:30 -07:00
Allan Shortlidge
2ba37da7e7 AST: Refactor AvailabilityContext::PlatformInfo operations. 2024-10-22 08:39:29 -07:00
swift-ci
94063a282e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-21 23:14:44 -07:00
Allan Shortlidge
b346385544 AST: Refactor AvailabilityContext into a value type.
Make the pointer to uniqued storage an implementation detail of an
`AvailabilityContext` value. This way clients of `AvailabilityContext` don't
need to think about pointers and can have access to mutating operations on a
context when appropriate.
2024-10-21 15:16:08 -07:00
Allan Shortlidge
0730209302 AST: Move AvailabilityContext into its own header and cpp file. 2024-10-21 15:16:08 -07:00
Allan Shortlidge
4cb783fc92 AST: Store unavailability and deprecation status in AvailabilityContext. 2024-10-21 15:16:08 -07:00
Jakub Florek
1d94844322 Add SwiftLexicalLookup validation. 2024-10-20 12:12:22 +02:00
swift-ci
559b5c5923 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 23:07:29 -07:00
Allan Shortlidge
1e7cc98a4b Merge pull request #77083 from tshortli/introduce-availability-context 2024-10-17 22:59:52 -07:00
swift-ci
5bfc87531f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 18:21:11 -07:00
Michael Gottesman
1a07030a0a Merge pull request #77028 from gottesmm/swift_task_runOnMainActor
[concurrency] Implement swift_task_runOnMainActor/hop to main actor thunk
2024-10-17 18:11:24 -07:00
Allan Shortlidge
47e41855d0 AST/Sema: Adopt AvailabilityContext in TypeRefinementContext.
Begin using `AvailabilityContext` as the availability representation in
`TypeRefinementContext`, instead of only storing platform introduction
availability ranges.

There should be no functional changes since this just changes the
representation of the existing information stored by `TypeRefinementContext`.
However, in the future `AvailabilityContext` will be expanded to represent
additional availability constraints.
2024-10-17 17:32:05 -07:00
swift-ci
1a68118042 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 15:14:32 -07:00
Allan Shortlidge
6a4b1cc4b0 Merge pull request #77082 from tshortli/reorder-ctor-warning
IRGen: Resolve a noisy `-Wreorder-ctor` warning
2024-10-17 15:06:33 -07:00
Michael Gottesman
0e0665bfbd [concurrency] Add support for HopToMainActorIfNeededThunk.
It is behind the experimental flag GenerateForceToMainActorThunks.
2024-10-17 13:31:39 -07:00
swift-ci
848b66dca6 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 12:15:00 -07:00
Gábor Horváth
c76f894c19 Merge pull request #77073 from swiftlang/gaborh/lifetimebound-add-diagnostics
[cxx-interop] Diagnose misuses of escapability and lifetimebound
2024-10-17 20:04:08 +01:00
Allan Shortlidge
8d3fa35377 IRGen: Resolve a noisy -Wreorder-ctor warning. 2024-10-17 11:33:21 -07:00
Allan Shortlidge
439c5951ec AST: Introduce AvailabilityContext.
This class is designed to be a compact representation of the active
availability constraints in a specific scope. For now, it only models platform
introduction availability but it will soon be updated to cover additional
availability constraints, like platform unavailability.

In anticipation of needing to reference `AvailabilityContext`s from
`TypeRefinementContext`s and increasing memory requirements for these contexts,
a cache of uniqued instances of `AvailabilityContext` are stored in a
`llvm::FoldingSet` on `ASTContext`.
2024-10-17 11:26:28 -07:00
Michael Gottesman
f0f5ad54fd [thunk-lowering] Add support for mangling identity thunks.
This is just again using identity thunks to show that the behavior works before
I add in hop to main actor.
2024-10-17 11:17:38 -07:00
swift-ci
e90f070b60 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 08:08:55 -07:00
Gábor Horváth
9325512998 Merge pull request #77025 from swiftlang/gaborh/support-objc-protocols
[cxx-interop] Support ObjC protocols in C++ interop
2024-10-17 15:38:17 +01:00
Gabor Horvath
e86cf185e2 [cxx-interop] Diagnose misuses of escapability and lifetimebound
When a type is explicitly annotated as escapable or non-escapable it has
requirements about the lifetime annotations. This patch introduces
diagnostics to detect that.
2024-10-17 15:35:55 +01:00
swift-ci
ffb7eef5ab Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 05:15:25 -07:00
Arnold Schwaighofer
4e931e7638 Merge pull request #76849 from aschwaighofer/prof_thunks
IRGen: Add the ability to mark certain generic entry points in back traces
2024-10-17 05:12:06 -07:00
Gabor Horvath
0e03d342fe [cxx-interop] Support ObjC protocols in C++ interop
This patch introduces handling of ObjC protocols similar to how ObjC
classes work. Since this only works in ObjC++, all declarations
containing ObjC protocols will be protected by the __OBJC__ macro.

This patch results in some `_bridgeObjC` methods being exposed, we might
end up hiding those in the future, but there is no harm having them in
the interop header for the interim period.

rdar://136757913
2024-10-16 18:51:35 +01:00
swift-ci
4ac1f2887f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-15 10:16:56 -07:00
Egor Zhdan
844d103f0d Merge pull request #77006 from swiftlang/egorzhdan/cxx-contiguous
[cxx-interop] Add `UnsafeCxxContiguousIterator` & `UnsafeCxxMutableContiguousIterator` protocols
2024-10-15 19:01:15 +02:00
Egor Zhdan
3a200deee9 [cxx-interop] Add UnsafeCxxContiguousIterator & UnsafeCxxMutableContiguousIterator protocols
This adds a pair of Swift protocols that represents C++ iterator types conforming to `std::contiguous_iterator_tag` requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as `std::vector` from Swift, for instance, by providing an overload of `withContiguousStorageIfAvailable` for contiguous containers.

rdar://137877849
2024-10-15 14:30:09 +01:00
swift-ci
fa5fc7948e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-14 21:45:47 -07:00
Allan Shortlidge
7819dd7833 AST/Sema: Remove unnecessary ASTContext parameters from availability APIs.
Many of the methods on `AvailabilityInference` take both a `Decl` and an
`ASTContext`, which is redundant.
2024-10-14 17:46:53 -07:00