Commit Graph

44444 Commits

Author SHA1 Message Date
Michael Gottesman
d060f01527 Merge pull request #78837 from gottesmm/rdar-142661388
[rbi] Change Region Based Isolation for closures to not use the AST and instead just use SIL.
2025-01-23 15:48:34 -08:00
Rintaro Ishizaki
740f0b2fec Merge pull request #78838 from rintaro/astprinter-interfacemode-rdar131726756
[ASTPrinter] Print SPI by default
2025-01-23 14:21:11 -08:00
Allan Shortlidge
2f34f1d9cf Merge pull request #78829 from tshortli/semantic-available-attr-request
AST: Introduce SemanticAvailableAttrRequest
2025-01-22 22:31:57 -08:00
Rintaro Ishizaki
37a2748e0d [ASTPrinter] Print SPI by default
`PrintOptions.InterfaceContentKind` was not initialized. Set it to
`InteraceMode::Private` by default, so SPI declarations and their `@_spi`
attribues are printed. This basically restores the behavior before
aba3b6c24e , and is align with
`AccessFilter` being `AccessLevel::Private` by default.

rdar://131726756
2025-01-22 21:37:54 -08:00
Michael Gottesman
082b824a8e [rbi] Change Region Based Isolation for closures to not use the AST and instead just use SIL.
The reason why I am doing this is that in certain cases the AST captures indices
will never actually line up with partial apply capture indices since we seem to
"smush" together closures and locally defined functions.

NOTE: The reason for the really small amount of test changes is that this change
does not change the actual output by design. The only cases I had to change were
a case where we began to emit a better diagnostic and also where I added code
coverage around _ and let _ since those require ignored_use to be implemented so
that they would be diagnosed (previously we just did not emit anything so we
couldn't emit the diagnostic at the SIL level).

rdar://142661388
2025-01-22 21:12:36 -08:00
Michael Gottesman
7ae56aab2e [sil] Add a new instruction ignored_use.
This is used for synthetic uses like _ = x that do not act as a true use but
instead only suppress unused variable warnings. This patch just adds the
instruction.

Eventually, we can use it to move the unused variable warning from Sema to SIL
slimmming the type checker down a little bit... but for now I am using it so
that other diagnostic passes can have a SIL instruction (with SIL location) so
that we can emit diagnostics on code like _ = x. Today we just do not emit
anything at all for that case so a diagnostic SIL pass would not see any
instruction that it could emit a diagnostic upon. In the next patch of this
series, I am going to add SILGen support to do that.
2025-01-22 21:12:36 -08:00
kntk
bdfb6099b2 [ConstraintSystem] Add index value (as an impact of the score kind) to output of debug constraints. (#78740)
* [ConstraintSystem] Add index value (as an impact of the score kind) to debug constraints.

* Use weight instead of index, change label 'value' -> 'impact'

* Fix debug constraints output format: remove 'components' and add 'weight' label
2025-01-22 17:52:56 -08:00
Allan Shortlidge
dfc741e30a AST: Optimize storage of VersionTuples in AvailableAttr.
Representing introduced, deprecated, and obsoleted versions at rest as optional
version tuples is redundant, since the empty version tuple already represents
"version not present".

NFC.
2025-01-22 16:01:19 -08:00
Allan Shortlidge
2908520841 AST: Introduce SemanticAvailableAttrRequest.
This request will finish type checking an AvailableAttr by resolving its domain
and then enforcing any restrictions that the domain has on the attribute, like
disallowing version specifications.

This change just introduces the request and plumbs it through. NFC.
2025-01-22 16:01:19 -08:00
Artem Chikin
ea2c501131 Merge pull request #78672 from artemcm/DepScanInvalidRejectedBinaryModulesWarn
[Dependency Scanning] Emit a warning when failing to load a binary module of a non-resilient dependency
2025-01-22 15:03:43 -08:00
Anthony Latsis
499146df88 Merge pull request #78739 from AnthonyLatsis/hatzegopteryx
TypeCheckType: Rework IUO diagnostics using behavior limitation
2025-01-22 19:12:02 +00:00
Allan Shortlidge
190779ecd4 Merge pull request #78797 from tshortli/availability-context-unavailable-domain
AST: Track an unavailable domain instead of platform in AvailabilityContext
2025-01-22 10:31:51 -08:00
Joe Groff
5d0fe0a156 Merge pull request #78705 from jckarter/explicit-conditional-invertible-extension-requirements
Require explicit statement of all `Copyable`/`Escapable` requirements for conditional `Copyable`/`Escapable` conformances.
2025-01-22 09:52:26 -08:00
Tony Allevato
400b21fc82 Merge pull request #78808 from allevato/strictness-fixes
[NFC] Include `<cstdlib>` and `<cstdint>` where necessary.
2025-01-22 11:54:45 -05:00
Allan Shortlidge
fe138e014a AST: Track an unavailable domain instead of platform in AvailabilityContext.
Now that most of the compiler tracks availability in terms of
AvailabilityDomain, it's time to do so in AvailabilityContext as well. This
will ensure that the compiler accurately suppresses diagnostics about a decl
being unavailable in an arbitrary domain when the context of the use is already
unavailable in that domain.

With this change, most of the special-casing for the Embedded Swift availability
domain has been removed from the compiler, outside of parsing and interface
printing.
2025-01-22 06:40:11 -08:00
Allan Shortlidge
b8c4298a07 AST: Introduce AvailabilityDomain::contains().
This operation describes the partial ordering with which Availability domains
form a lattice.

As a temporary measure, a containment ordering needs to be specified for the
Swift language, Embedded, and Package Description domains. Without this
ordering, there won't be a way for AvailabilityContext to preserve the
invariant that the unavailable domain of a child context contains the
unavailable domain for the parent. However, once AvailabilityContext is
refactored to represent the status of multiple availability domains
simultaneously, the ordering of these domains relative to each other can be
relaxed.

NFC.
2025-01-22 06:40:10 -08:00
Tony Allevato
3bd71c9d62 [NFC] Include <cstdlib> and <cstdint> where necessary.
Our Bazel builds have become more strict about libc++
dependencies recently, so these are required to pick up
declarations of `malloc` and `uint32_t`, respectively.
2025-01-22 07:47:16 -05:00
Allan Shortlidge
52b89a8ee0 Merge pull request #78805 from tshortli/private-available-attr-fields
AST: Eliminate remaining direct access to AvailableAttr's fields
2025-01-22 03:41:30 -08:00
Becca Royal-Gordon
ebea19d7b9 Merge pull request #78697 from beccadax/rdar142693093
Work around Foundation NS_TYPED_ENUM bug
2025-01-22 00:57:41 -08:00
Allan Shortlidge
ba822d1e23 AST: Eliminate remaining direct access to AvailableAttr's fields.
Most of the compiler should use SemanticAvailableAttr instead. In contexts like
ASTDumper where a semantic attribute is unavailable use accessors on
AvailableAttr.

NFC.
2025-01-21 22:56:07 -08:00
John Hui
1341516dba [cxx-interop] Fix spurious ambiguous member lookup for eagerly imported members (#78673)
Follow-up from #78132, which did not fix issues related to eagerly imported members like subscripts.

This patch restructures recursive ClangRecordMemberLookup requests to importBaseMemberDecl() in the recursive calls, rather than propagating base member decls up to the initial lookup request and doing the import. Doing so seems to fix lingering resolution issues (which I've added to the regression tests).

rdar://141069984
2025-01-21 22:06:09 -08:00
Allan Shortlidge
e17c36dc3b Merge pull request #78788 from tshortli/availability-context-gardening
AST: AvailabilityContext gardening
2025-01-21 20:33:11 -08:00
Allan Shortlidge
0f1e301fb8 Merge pull request #78775 from tshortli/replace-unavailability-diagnostic-info
Sema: Replace UnavailabilityDiagnosticInfo with AvailabilityConstraint
2025-01-21 20:28:58 -08:00
Becca Royal-Gordon
0ce403d680 [NFC] Add some pretty stack traces
These would have helped us to debug rdar://142693093 more quickly.
2025-01-21 17:33:09 -08:00
Anthony Latsis
35f1370f6e TypeCheckType: Rework IUO diagnostics using behavior limitation
Also stop suggesting a '?' fix-it for casts, where it is not likely to
be helpful because the common intention is either to force the optional
or declare an IUO.
2025-01-21 21:41:00 +00:00
Allan Shortlidge
0b5d787a73 AST: Rename AvailabilityContext::PlatformInfo.
It's about to get updated to contain more than just platform-specific
availability context information.

NFC.
2025-01-21 11:44:28 -08:00
Allan Shortlidge
c615faacd7 AST: Rename AvailabilityContext's storage member.
NFC.
2025-01-21 11:44:27 -08:00
Joe Groff
a0a26b8330 Require explicit statement of all Copyable/Escapable requirements for conditional Copyable/Escapable conformances.
As specified by the SE-0446 acceptance, extensions that declare a type's
conditional `Copyable` or `Escapable` ability must reiterate explicitly all
of the `Copyable` and/or `Escapable` requirements, whether required or not
required (by e.g. `~Copyable`) that were suppressed in the original
type declaration.
2025-01-21 09:36:39 -08:00
Pavel Yaskevich
82e111a276 Merge pull request #78704 from xedin/rdar-142920095
Implement experimental`@execution(concurrent | caller)` attribute
2025-01-21 09:04:39 -08:00
Allan Shortlidge
31fa5fc347 Sema: Replace UnavailabilityDiagnosticInfo with AvailabilityConstraint.
AvailabilityConstraint models a superset of UnavailabilityDiagnosticInfo and
will become the currency type for unsatisfied availability everywhere. NFC.
2025-01-21 08:51:29 -08:00
Allan Shortlidge
0720d4fd1c Merge pull request #78764 from tshortli/availability-constrain-pointer-int-pair 2025-01-20 22:34:38 -08:00
Saleem Abdulrasool
f753db23a9 Merge pull request #78712 from compnerd/violated-by-the-odr
Basic: fix a small corner case for ODR violations
2025-01-20 18:57:59 -08:00
Allan Shortlidge
6e1f0ae1c8 AST: Use PointerIntPair in AvailabilityConstraint.
Now that SemanticAvailableAttr is pointer-like, AvailabilityConstraint can be
pointer sized too.

NFC.
2025-01-20 18:24:04 -08:00
Allan Shortlidge
40b3fccc08 Merge pull request #78743 from tshortli/embedded-swift-availability-domain
AST: Model Embedded Swift availability with a domain
2025-01-20 15:00:17 -08:00
Allan Shortlidge
17e2262449 Revert "AST: Print opaque result types correctly in swiftinterfaces."
This reverts commit 902892a59f.
2025-01-19 09:56:51 -08:00
Allan Shortlidge
691f6fc646 AST: Model Embedded Swift availability with a domain.
Remove the bit on AvailableAttr that previously modeled this.

Resolves rdar://138802876.
2025-01-19 08:52:53 -08:00
Pavel Yaskevich
c89ba5f58c [Sema] Diagnose clash between inferred global actor isolation and @execution(concurrent) 2025-01-17 15:40:01 -08:00
Pavel Yaskevich
b1e30b22b9 [Sema] Impliment initial validation of @execution(concurrent) attribute 2025-01-17 15:40:01 -08:00
Pavel Yaskevich
667a976ec5 [ASTGen] Add support for @execution(...) attribute 2025-01-17 15:40:01 -08:00
Pavel Yaskevich
0445e5af5f [Parse] Implement parsing of @execution(...) decl attribute 2025-01-17 15:40:01 -08:00
Pavel Yaskevich
ca96a2b060 [AST] Define @execution(concurrent | caller) attribute on function declarations 2025-01-17 15:40:00 -08:00
Artem Chikin
550538f3b5 [Dependency Scanning] Emit a warning when failing to load a binary module of a non-resilient dependency
This failure will most-likely result in the dependency query failure which will fail the scan. It will be helpful if the scanner emitted diagnostic for each such module it rejected to explain the reason why.

Resolves rdar://142906530
2025-01-17 10:52:10 -08:00
Saleem Abdulrasool
d4c2e1cedb Basic: fix a small corner case for ODR violations
When building the runtime we define `SWIFT_RUNTIME`. `swiftCore_EXPORTS`
is only defined when building swiftCore as a shared library. This would
thus allow the ODR violations to appear in a static library form of the
standard library. This was uncovered with the new runtime build system.
2025-01-17 10:41:07 -08:00
Allan Shortlidge
87308e37f1 AST: Avoid creating duplicate AvailabilityScopes under SequenceExprs.
Since availability scopes may be built at arbitrary times, the builder may
encounter ASTs where SequenceExprs still exist and have not been folded, or it
may encounter folded SequenceExprs that have not been removed from the AST.

To avoid a double visit, track whether a SequenceExpr is folded and then
customize how ASTVisitor handles folded sequences.

Resolves rdar://142824799 and https://github.com/swiftlang/swift/issues/78567.
2025-01-17 10:21:22 -08:00
Saleem Abdulrasool
0e77477147 Merge pull request #78553 from compnerd/well-known-imports
IRGen: further generalise runtime function generation
2025-01-16 09:25:54 -08:00
Slava Pestov
d1d2411bf3 Merge pull request #78267 from slavapestov/incremental-bindings-part-0
Sema: Some small cleanups in CSBindings.cpp and related code
2025-01-16 09:03:32 -05:00
Venkatesh Sriram
a5cc53f356 Merge pull request #78511 from venkatesh5789/null-value-optional-extraction
[Compile Time Constant Extraction] Extract Nil Values for Optionals
2025-01-16 18:43:07 +05:30
Alastair Houghton
d6447284f8 Merge pull request #78514 from al45tair/eng/PR-137201928
[Backtracing] Update module maps.
2025-01-16 11:21:33 +00:00
Venkatesh Sriram
c6c8526b87 [Compile Time Constant Extraction] Extract Nil Values for Optionals 2025-01-16 12:04:03 +05:30
Anthony Latsis
99c3802e02 Merge pull request #78669 from AnthonyLatsis/andromeda
[NFC] Add some unit tests for diagnostic behaviors
2025-01-16 06:30:56 +00:00