Commit Graph

2698 Commits

Author SHA1 Message Date
Pavel Yaskevich
11ef6e58d8 Merge pull request #71659 from xedin/noncopyable-circularity-fixes
[AST/Sema] NonCopyableGenerics: Address some of the request circularity issues
2024-02-20 12:38:16 -08:00
Pavel Yaskevich
b6af269933 [AST] Remove TypeDecl::hasInverse and move canBe{Copyable, Escapable} to NominalTypeDecl` 2024-02-19 13:04:44 -08:00
Pavel Yaskevich
c81db8e149 [AST] NonCopyableGenerics: Expand hasInverseMarking to support associated type declarations
This is required for `ASTPrinter` to wrap the protocol that has
associated type with inverses in a feature block.
2024-02-19 10:37:16 -08:00
Pavel Yaskevich
cc7258152c [AST] NoCopyableGenerics: Remove last use of getMarking(...)
Introduce `NominalTypeDecl::has{Marking, InverseMarking}` methods
that split the logic from `InvertibleAnnotationRequest`
2024-02-16 17:55:52 -08:00
Pavel Yaskevich
355e02d7e9 [AST] Route inverse marking detection through TypeDecl::hasInverseMarking
The first step on the path to dismangle `TypeDecl::getMarking()`.
2024-02-16 17:55:52 -08:00
Pavel Yaskevich
3257ff4755 [AST] Move hasInverseMarking into ProtocolDecl and produce a loc of found inverse 2024-02-16 17:55:52 -08:00
Ellie Shin
3a80ed705b Merge pull request #71663 from apple/es-bypass-opt
Move in-package resilience bypassing logic to a resilience check with accessing module
2024-02-16 14:12:35 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Ellie Shin
0802ff507e Move bypassing resilience in package logic to
isResilient(ModuleDecl, ResilienceExpansion).

isResilient() returns the decl's resilience by definition
and should not be altered whether bypassing optimization
is enabled or not. The overloaded isResilient(ModuleDecl..)
is used for accessing a decl from a client module, which is
the appropriate place to opt in for non-resilience in package.

Resolves rdar://123031292
2024-02-15 13:04:51 -08:00
Allan Shortlidge
9bb2744df1 Merge pull request #71614 from tshortli/unavailable-decl-optimization-application-extensions
AST: Don't optimize decls that are unavailable in extensions
2024-02-15 09:41:27 -08:00
Allan Shortlidge
2967b80e1a AST: Ignore availability attrs for app extension platforms in some queries.
When determining whether a declaration should be considered unavailable at
runtime, ignore `@available` attributes for application extension platforms but
continue searching for other `@available` attributes that might still make the
declaration unavailable. This ensures corner cases like these are handled:

```
// Dubious, but allowed
@available(macOS, unavailable)
@available(macOSApplicationExtension, unavailable)
public func doublyUnavailableOnMacOSFunc() {}

// Expresses an uncommon, but valid constraint
@available(macCatalyst, unavailable)
@available(iOSApplicationExtension, unavailable)
public func confusingDiamondAvailabilityInheritanceFunc() {}
```
2024-02-14 18:31:43 -08:00
Michael Gottesman
23ab974574 Merge pull request #71567 from gottesmm/transferring-param
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
2024-02-14 17:54:48 -08:00
Michael Gottesman
f3edb5730a [transferring] Add support for transferring results.
rdar://121324697
2024-02-14 14:39:02 -08:00
Michael Gottesman
bf2ec7eb85 [transferring] Change transferring to no longer be a ParamSpecifier.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.

NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.

rdar://121324715
2024-02-14 13:04:46 -08:00
Michael Gottesman
1f0527d47f [ast] Rename ParamSpecifier::{Transferring,ImplicitlyCopyableConsuming}.
The reason why I am doing this is that I am going to be changing transferring to
not be a true ParamSpecifier. Instead, it is going to be a bit on Param that
changes the default ParamSpecifier used. That being said, I cannot use consuming
for this purpose since consuming today implies no implicit copy semantics, which
we do not want unless the user specifically asks for it by writing consuming.
2024-02-14 13:04:21 -08:00
Ellie Shin
f5150e7265 Remove AbstractStorageDecl::isFormallyResilient.
Update DeclContext::bypassResilienceInPackage.
2024-02-13 19:09:31 -08:00
Ellie Shin
4588cc2261 Support bypassing resilience checks for package decls at use site in a package.
By default package decls are treated as resilient, similar to public (non-frozen).
This PR adds support to allow direct access to package decls at use site if opted-in.
Requires the loaded module to be a binary module in the same package.

Resolves rdar://121626315
2024-02-13 19:09:31 -08:00
Becca Royal-Gordon
7aa5b7fd88 Merge pull request #71445 from beccadax/category-error 2024-02-13 11:13:48 -08:00
Pavel Yaskevich
a6a2a74c9b [SILOptimizer] Distributed: Suppress signature specialization for witnesses with ad-hoc serialization requirement 2024-02-12 14:26:30 -08:00
Becca Royal-Gordon
9bcd818fb1 [NFC] Make objcImpl request one-to-many
An @_objcImpl extension with no category name *should* implement not only the class’s main @interface, but also any class extension @interfaces. Start making this true by making ObjCInterfaceAndImplementationRequest return all of these decls as the interfaces for such an implementation.

This commit doesn’t actually change Sema or IRGen to process the extra interfaces, so it’s NFC.
2024-02-09 21:32:06 -08:00
Becca Royal-Gordon
11977682b6 [NFC] Cache objcImpl requests in ClangImporter
This reduces the memory overhead of objcImpl from one word per Decl to one bit per Decl, at the cost of making cache lookups slightly slower (but it will only be consulted once for non-objcImpl decls, which is by far the most common case).
2024-02-08 20:34:31 -08:00
Andrew Trick
e738b8a77e Merge pull request #71353 from meg-gupta/initlifetimedep
Support for lifetime dependence specifiers on initializers
2024-02-05 08:55:54 -08:00
Meghana Gupta
0835d00972 Add serialization/deserialization support to lifetime depedence on initializers 2024-02-02 11:50:14 -08:00
Meghana Gupta
c8ece100ba Handle explicit lifetime dependence specifiers in initializers 2024-02-02 11:50:10 -08:00
Pavel Yaskevich
4e5e6ccf00 [AST/TypeChecker] NFC: Transform findImportFor into ValueDecl::findImport 2024-02-01 14:14:22 -08:00
Meghana Gupta
2180221247 Serialize/deserialize LifetimeDependenceInfo 2024-02-01 07:39:51 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
Slava Pestov
d8f85a3bf6 AST: Remove ProtocolDecl::getRequirementSignatureAsGenericSignature() 2024-01-31 21:56:57 -05:00
Joe Groff
a52e96e358 Merge pull request #71263 from jckarter/borrowing-switch-3
Parse `_borrowing x` in patterns as a borrow binding.
2024-01-31 07:08:32 -08:00
Joe Groff
6706feaf5e Parse _borrowing x in patterns as a borrow binding.
Treat it as a contextual keyword when followed by an identifier, like our
other ownership-related declarations and operators.
2024-01-30 17:33:42 -08:00
Hamish Knight
9b64990d24 [AST] Remove the "single expression body" bit
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
2024-01-30 14:08:54 +00:00
Hamish Knight
9cf8f5b1f0 [AST] Remove AbstractFunctionDecl::getSingleExpressionBody
This is now unused.
2024-01-30 14:08:54 +00:00
Hamish Knight
d5a3e36309 [AST] Remove AbstractFunctionDecl::setSingleExpressionBody
This is now unused.
2024-01-30 14:08:53 +00:00
Kavon Farvardin
58480c3be1 [NCGenerics] provide namespace for CanBeInvertible 2024-01-23 22:42:38 -08:00
Kavon Farvardin
b4985f7fde [NFC] replace canBeNoncopyable
First, "can have an absence of Copyable" is a rather confusing notion,
so the query is flipped to "can be Copyable". Next, it's more robust to
ask if a conformance exists for the TypeDecl to answer that question,
rather than trying to replicate what happens within that conformance
lookup.

Also renames `TypeDecl::isEscapable` to match.
2024-01-23 22:42:38 -08:00
Hamish Knight
fd97268393 Merge pull request #70983 from hamishknight/another-cleanup
[AST] Remove SerializedLocalDeclContext
2024-01-22 18:49:42 +00:00
Pavel Yaskevich
57bf9d52b1 Merge pull request #71014 from xedin/inheritedentry-bitfields
[AST] NFC: Convert `InheritedEntry` flags to bitfields
2024-01-19 16:19:47 -08:00
Pavel Yaskevich
7f6a8f865c [AST] NFC: Convert InheritedEntry flags to bitfields 2024-01-19 10:22:39 -08:00
Michael Gottesman
9513d298ec [region-isolation] Add parsing/serialization/type system support for a transferring OwnershipSpecifier. 2024-01-18 13:20:28 -08:00
Hamish Knight
3f4b45b012 [AST] Remove SerializedLocalDeclContext
It's not clear that its worth keeping this as a
base class for SerializedAbstractClosure and
SerializedTopLevelCodeDecl, most clients are
interested in the concrete kinds, not only whether
the context is serialized.
2024-01-18 12:03:52 +00:00
Hamish Knight
f6b7301259 Merge pull request #70591 from hamishknight/doritos-and-fritos
[AST] A couple of PatternBindingInitializer cleanups
2024-01-18 11:33:19 +00:00
Hamish Knight
990d15567d [AST] Split up PatternBindingDecl::setPattern
Most clients only want to set one of the two
parameters, split it into `setPattern` and
`setInitContext` (the latter of which now
handles calling `setBinding`).
2024-01-17 16:02:33 +00:00
Hamish Knight
47f7a31095 [AST] Tighten up type of InitContext
Switch from promising a DeclContext to a
PatternBindingInitializer.

This has a couple of benefits:
- It eliminates a few places where we were force
`cast`'ing to PatternBindingInitializer.
- It improves the clarity of what's being stored,
it's not whatever the parent context of the
initializer is, it's specifically the
PatternBindingInitializer context if it exists.
2024-01-17 16:02:33 +00:00
Pavel Yaskevich
233d279a5c [AST] Support @preconcurrency attribute on test/extension inheritance entries 2024-01-16 10:30:58 -08:00
Doug Gregor
b31133e67d Ensure that freestanding macros get consistent discriminators
Due to the duality between the expression and declaration forms of
freestanding macros, we could end up assigning two different discriminators
to what is effectively the same freestanding macro expansion. Across
different source files, this could lead to inconsistent discriminators in
different translation units. Unify the storage of the discriminator to
avoid this issue.

Fixes rdar://116259748
2024-01-11 08:18:28 -08:00
Kavon Farvardin
778a413745 [NCGenerics] ensure ExistentialLayout is minimal
Instead of injecting Copyable & Escapable protocols into every
ExistentialLayout, only add those protocols if the existing protocols
don't already imply them. This simplifies things like `any Error`
protocol, so it still only lists one protocol in its existential layout.
But existentials like `any NoCopyP` still end up with a Copyable in its
layout.
2024-01-10 19:37:21 -08:00
Meghana Gupta
d3e921dc47 Make _resultDependsOn available on SILFunctionArgument 2023-12-29 01:57:19 -08:00
Sima Nerush
2fd5843a79 Merge pull request #70355 from simanerush/pack-iteration-fixes
[SE-0408] Pack iteration review feedback!
2023-12-16 09:50:31 -08:00
Sima Nerush
0482bd3652 [Sema] Refactor code and improve documentation pertaining to SE-0408. 2023-12-15 20:39:40 -08:00
Hamish Knight
2f25d8fa58 [AST] Compute SubscriptDecl EndLoc
Instead of having the parser set it, compute it
using the recorded brace location for the accessor
record.
2023-12-15 21:44:31 +00:00