Commit Graph

47728 Commits

Author SHA1 Message Date
Aidan Hall
c7af4c584e Bridging: APIs for PackSpecialization pass 2025-10-26 13:44:34 +00:00
Hamish Knight
62f0926d25 [CS] Invalidate nested unresolved VarDecls when ignoring completion argument
Make sure we set types for any nested VarDecls in UnresolvedPatternExprs
to ensure we don't crash when attempting to solve the body.
2025-10-26 12:33:29 +00:00
Michael Gottesman
a0d33c3e7e Merge pull request #85118 from gottesmm/irgen-builtin-fixes
[irgen] Convert emitIRGenBuiltin to use a covered switch.
2025-10-25 18:29:21 -07:00
Hamish Knight
55ebd0774e [AST] Avoid exposing lazy local storage var to name lookup
We already reject attempts to reference this for `lazy` properties.
For `lazy` locals let's just not expose it to name lookup to begin
with. This ensures we don't attempt to prematurely kick the interface
type computation for the var, fixing a couple of crashers.
2025-10-25 15:07:11 +01:00
Hamish Knight
a341c86f3c [AST] NFC: Rename VarDecl::visitAuxiliaryDecls -> visitAuxiliaryVars
Make it more obvious it's different to `Decl::visitAuxiliaryDecls`.
2025-10-25 15:07:11 +01:00
Allan Shortlidge
17a87065b7 Merge pull request #85130 from tshortli/refactor-version-remap
AST: Refactor availability version remapping
2025-10-25 01:40:42 -07:00
Kavon Farvardin
03d61ed75a Merge pull request #85090 from kavon/manual-ownership/usability-fixes-6
ManualOwnership: provide ability to apply to entire compilation unit
2025-10-25 00:15:03 -07:00
Anton Korobeynikov
186f88bead [AutoDiff] Fix two issues related with emission of differentiability witnesses (#80983)
1. When differentiable nested function (closure) is specialized by capture promotion pass ensure we generate a differentiability witness for the specialized function as well. Ensure the original witness is removed if the original function becomes dead. 
2. Differentiability witnesses for a function could originate either from its `@differentiable` attribute or from explicit `@derivative(of:)` attribute on the derivative. In the latter case the derivative itself might not be emitted, while original function is (e.g. original function is `@inlineable`, but derivative is `@usableFromInline`). Previously both cases were handled only when function body was emitted. As a result we missed witness in the aforementioned case. Ensure the
differentiability witness originating from `@derivative(of:)` is emitted even if we're not going to emit body of the derivative.

Fixes #59135
2025-10-24 20:02:08 -07:00
Kavon Farvardin
2d881bdc9c ManualOwnership: provide ability to apply to entire compilation unit
With this patch, I'm flipping the polarity of things.

The flag `-enable-experimental-feature ManualOwnership` now turns on the diagnostics,
but they're all silenced by default. So, you need to add -Wwarning or -Werror to
your build settings to turn on the specific diagnostics you care about.

These are the diagnostic groups relevant to the feature:

- SemanticCopies aka "explicit copies mode"
- DynamicExclusivity

For example, the build setting `-Werror SemanticCopies` now gives you errors about
explicit copies, just as before, but now you can make them just warnings with -Wwarning.

To opt-out a declaration from everything when using the feature, use @_noManualOwnership.

@_manualOwnership is no longer an attribute as a result.

resolves rdar://163372569
2025-10-24 18:54:07 -07:00
Allan Shortlidge
05f7cb7017 AST: Refactor availability version remapping.
Availability version remapping currently only applies to code built for
visionOS. We plan to introduce more platform kinds and standalone availability
domains that will require version remapping, though, so it's time to
rearchitect and simplify the code to make it easier to generalize.

`AvailabilityDomain` is now responsible for version remapping and much of the
previously duplicated utilities have been consolidated.
2025-10-24 17:22:07 -07:00
Kavon Farvardin
135e02c1d9 ManualOwnership: improve diagnostics & testing 2025-10-24 16:59:44 -07:00
Kavon Farvardin
6b858b411c ManualOwnership: introduce 'DynamicExclusivity'
We can add warnings about dynamic exclusivity
checks that may happen on an access, with
explainers about why they happen for safety.
2025-10-24 16:59:44 -07:00
Kavon Farvardin
95a6719117 ManualOwnership: introduce 'SemanticCopies' diagnostic group
This includes documentation to explain how to understand
these diagnostics.
2025-10-24 16:59:41 -07:00
Becca Royal-Gordon
e6d8b02626 Make module selectors non-experimental
Approved by SE-0491.
2025-10-24 16:23:50 -07:00
Becca Royal-Gordon
e3495f5fe7 Forbid module selectors on dependent member types
In code like the following:

```
protocol P { associatedtype A: Hashable }
protocol Q { associatedtype A: Comparable }

func fn<T: P & Q>(_: T) where T.A == Int { … }
```

`T.A` is actually the union of `P.A` and `Q.A`—it satisfies both associated types and has both of their constraints. This means it doesn’t actually make sense to apply a module selector to `A`—even if `P` and `Q` are in different modules, `T.A` always represents both of the declarations, not one or the other. We therefore now ban module selectors in this position, since they don’t actually jibe with the nature of a generic signature.

This justification technically doesn’t hold for *every* member type of a generic parameter—a member type can refer to a concrete typealias in a protocol extension, for instance—but in those situations, you can disambiguate (and add module selectors) by writing `P.A` or `Q.A` instead of `T.A`, so we’re not really worried about this limitation.
2025-10-24 16:23:50 -07:00
Becca Royal-Gordon
ec92be4955 Support module selectors for cross-import overlays 2025-10-24 16:23:50 -07:00
Becca Royal-Gordon
60cc537f70 Improve module selector constraint solver diagnostics 2025-10-24 16:23:49 -07:00
Becca Royal-Gordon
d1e391094d Improve module selector expr lookup diagnostics 2025-10-24 16:23:49 -07:00
Becca Royal-Gordon
7949224b69 Improve module selector type lookup diagnostics 2025-10-24 16:23:48 -07:00
Becca Royal-Gordon
ffaa35810c Handle lookup into Builtin with module selector
Lookups like Builtin::Int64 were failing because BuiltinUnit rejected all unqualified lookups. Make it allow unqualified lookups with a module selector.
2025-10-24 16:23:48 -07:00
Becca Royal-Gordon
7bf14de2e6 Handle module selectors with local vars right 2025-10-24 16:23:34 -07:00
Becca Royal-Gordon
b35aaef526 Handle module selectors in macro lookups 2025-10-24 16:23:34 -07:00
Becca Royal-Gordon
1dfc0bff86 Handle module selectors in qualified lookup 2025-10-24 16:23:33 -07:00
Becca Royal-Gordon
e662993a08 [NFC] Audit some DeclName➡️DeclNameRef conversions
Adds comments explaining why these conversions aren’t lossy.
2025-10-24 16:23:33 -07:00
Becca Royal-Gordon
64d8b70942 Make DeclNameRef able to store a module selector
In this commit, this change affects certain diagnostics but doesn’t actually alter name lookup behavior yet.
2025-10-24 16:23:33 -07:00
Becca Royal-Gordon
4991bf930f [NFC] Improve some lookup-related doc comments 2025-10-24 16:23:32 -07:00
Allan Shortlidge
88bc79f6af AST: Remove unnecessary ASTContext argument.
There's no need to take one as input to a method on `Decl`. NFC.
2025-10-24 16:20:02 -07:00
Meghana Gupta
7e8d8b671f Merge pull request #85097 from meg-gupta/withdiagpr
Update borrow accessor diagnostics and synthesis
2025-10-24 15:06:19 -07:00
Augusto Noronha
77db003169 Merge pull request #83582 from augusto2112/fix-elf-shnum
[RemoteInspection] Handle special case of large amount of ELF sections.
2025-10-24 13:21:41 -07:00
Kuba (Brecka) Mracek
eb23d3bc0a Merge pull request #85074 from kubamracek/section
SE-0492: Stabilize @_section/@_used into @section/@used
2025-10-24 12:29:48 -07:00
Michael Gottesman
239807faa1 [irgen] Convert emitIRGenBuiltin to use a covered switch.
This should make it easier to add new builtins by "following the warnings" and
prevent us from not handling a builtin in IRGen.

When I did this, I discovered that if I did this naively, we would have
AddressOf show up twice in the switch. This turned out to be because:

1. AddressOf is a SIL builtin that semantically is expected to only result in
SIL being emitted instead of having a builtin "addressof" be emitted.

2. For what ever reason, we actually had code in IRGen to emit an AddressOf
BuiltinInst if we saw it (which we never should have)... but also later code
asserted that we would never see it b/c it is a "SIL only builtin".

3. When I converted the if statements to be case statements, helpfully the
compiler told me I had a duplicate case. After investigation, I found the above
meaning that I was able to just delete the IRGen handling.

So now we properly handle AddressOf by asserting. As an additional tactic to
make "SIL only builtins" even more explicit, I added code to the SIL verifier
that validates we never see a builtin inst that is a "SIL only builtin" and
added some comments to Builtins.def that elaborate on this.
2025-10-24 11:50:21 -07:00
John Hui
781489f067 Merge pull request #85021 from j-hui/return-frt-diagnostics
[cxx-interop] Put RETURNS_RETAINED warnings in a diagnostic group

rdar://161932849
rdar://144976203
2025-10-24 12:05:48 -04:00
Hamish Knight
f15fae4737 Merge pull request #84822 from hamishknight/just-a-phase
[CS] Remove `ConstraintSystemPhase`
2025-10-24 16:05:08 +01:00
Hamish Knight
8397a7a61d Merge pull request #84907 from hamishknight/fixed-point
[CS] Penalize implicit pointer conversions to generic parameter types
2025-10-24 15:56:07 +01:00
Kavon Farvardin
38c61d7dd6 Merge pull request #85054 from kavon/opaque-values/fixes-3
OpaqueValues: add support for property wrappers
2025-10-23 22:18:54 -07:00
nate-chandler
9069d32078 Merge pull request #85055 from nate-chandler/general-coro/20251016/1
[CoroutineAccessors] Provide frame to de/allocation functions.
2025-10-23 20:17:52 -07:00
Adrian Prantl
cb4efa0839 Add a -debug-module-path frontend option
This new option allows the Driver to pass the path to a compilation
job's own binary swiftmodule artifact to the frontend. The compiler
then stores this path in the debug info, to allow clients like LLDB to
unambiguously know which binary Swift module belongs to which compile
unit.

rdar://163302154
2025-10-23 17:10:50 -07:00
Kuba Mracek
ca737d3d97 Tweak diagnostic text on @section/@const errors 2025-10-23 17:05:41 -07:00
Artem Chikin
9102c65102 Merge pull request #84938 from artemcm/ShareCacheRefInScanner
[Dependency Scanning] Have `ModuleDependnecyScanner` hold a reference to a dependency cache, instead of passing it around
2025-10-23 19:51:49 -04:00
Kavon Farvardin
19bd65c89b OpaqueValues: add support for property wrappers
resolves rdar://163071245
2025-10-23 16:31:01 -07:00
Hamish Knight
7f6a4da04e Merge pull request #85062 from hamishknight/not-the-bees 2025-10-23 22:39:58 +01:00
Ben Barham
ba04e5d35c Merge pull request #85026 from bnbarham/user-doc-cleanup
Cleanup user docs
2025-10-23 14:04:52 -07:00
Kuba (Brecka) Mracek
66eef684ee Merge pull request #80212 from kubamracek/object-file-format
Add #objectFormat compilation conditional (SE-0492)
2025-10-23 12:58:23 -07:00
Meghana Gupta
f44d7e53be Add diagnostics for ownership modifiers on borrow/mutate accessors 2025-10-23 11:49:10 -07:00
Augusto Noronha
266adaf1ea [RemoteMirrors] Add hook for resolving indirect addresses
Adds a hook so implementations of memory reader can add logic to
resolving remote addresses. This is needed because of an interaction
between LLDB, which tries to read memory from files instead of process
memory whenever possible and the DYLD shared cache.

The shared cache will merge pointers in the GOT sections from multiple
images into one location, and update the relative offsets to point to
the new location.
LLDB, will have initially read the offset pointing to the "old"
location, which will be zeroed out in live memory. This gives LLDB the
opportunity to re-read the relative offset, but from live memory, so it
can return the right pointer in the shared cache.

rdar://160837587
2025-10-23 11:35:45 -07:00
Pavel Yaskevich
2c1329e861 [ClangImporter] Add "suppressed" bit to SynthesizedProtocolAttr
Makes it possible to support `~Sendable` and potentially other
suppressible conformances.
2025-10-23 23:56:05 +09:00
Meghana Gupta
1dc5c9611c Intoduce unchecked_ownership instruction in raw SIL
This instruction can be used to disable ownership verification on it's result and
will be allowed only in raw SIL.

Sometimes SILGen can produce invalid ownership SSA, that cannot be resolved until
mandatory passes run. We have a few ways to piecewise disable verification.
With unchecked_ownership instruction we can provide a uniform way to disable ownership
verification for a value.
2025-10-23 05:19:08 -07:00
Meghana Gupta
e116df3628 Introduce return_borrow instruction 2025-10-23 05:18:59 -07:00
Hamish Knight
c7e9809480 [IDE] Mangle USRs using API decls rather than ABI decls
For semantic functionality the API decl is the more useful thing to
mangle, and redeclaration checking ensures we can't end up with
conflicts. This ensures we're able to perform a name lookup for the
decl based on its USR without having to maintain a separate lookup 
table for ABI names.
2025-10-23 09:11:17 +01:00
Hamish Knight
169096c233 [AST] Rename mangleDeclAsUSR -> mangleDeclWithPrefix
This is used by other things that don't necessarily want an IDE
USR.
2025-10-23 09:11:17 +01:00