Commit Graph

2456 Commits

Author SHA1 Message Date
Alex Hoppen
829e03c104 Merge pull request #79974 from a7medev/feature/complete-single-option-decl-attrs 2025-03-17 15:40:00 -07:00
Joe Groff
c949e6295f SIL: Lower fields that are conditionally addressable because of a dependency.
Parameters of generic type need to be treated as potentially
addressable-for-dependencies, but we don't want callers using the generic
function with concrete types that are known not to be addressable-for-
dependencies to be overconstrained. In SILFunctionType lowering, lower
these dependencies distinctly as conditionally addressable, meaning that
the dependency on an argument depends on whether the concrete type of
that argument is (potentially) addressable-for-dependencies or not.
2025-03-15 16:07:03 -07:00
Ahmed Mahmoud
78990ffe3f [IDE] Pass ParameterizedDeclAttributeKind to parseSingleAttrOption rather than completion callback 2025-03-14 13:19:53 +02:00
Ahmed Mahmoud
a340dca4b5 [IDE] Add parameter label comment for HasLabel 2025-03-14 04:48:22 +02:00
Ahmed Mahmoud
704e9fcc35 [IDE] Fix access control set completion as a declaration item 2025-03-14 04:45:07 +02:00
Ahmed Mahmoud
3bb2da0d0d [IDE] Remove unnecessary code complete checks 2025-03-14 04:44:26 +02:00
Ahmed Mahmoud
ab6ad401b3 [IDE] Consume identifier and ')' after parenthesized modifier
This fixes an issue where valid parenthesized modifiers like nonisolated(unsafe) get misinterpreted as function calls.
2025-03-14 02:34:04 +02:00
Ahmed Mahmoud
9767cc1158 [IDE] Remove duplicate code & add parameter label 2025-03-13 21:45:40 +02:00
Ahmed Mahmoud
c871e4962f [IDE] Recover from incomplete unowned and nonisolated in isStartOfSwiftDecl 2025-03-13 02:19:18 +02:00
Ahmed Mahmoud
951988c100 [IDE] Return Code Completion Status in Access Control Completion 2025-03-13 02:19:18 +02:00
Ahmed Mahmoud
78b4e851a7 [IDE] Complete unowned, nonisolated, access-control parameter 2025-03-13 02:19:18 +02:00
Ahmed Mahmoud
673d6a1d9f [IDE] Rename CustomSyntaxAttributeKind to ParameterizedDeclAttributeKind 2025-03-13 02:19:17 +02:00
Becca Royal-Gordon
7c867ca1da [NFC] Split DeclAttrOptions into two types
We’re running out of bits in DeclAttrOptions, so split it in two: DeclAttrRequirements contains all the `On*` options that describe the declarations allowed to have the attribute, while the other options are now DeclAttrBehaviors.

This commit also sorts the entries in DeclAttr.def by serialization code and improves the formatting of the file.
2025-03-12 14:14:16 -07:00
Gabor Horvath
22e2276c4f [cxx-interop] Do not require the LifetimeDependence feature in _SwiftifyImport
We use experimental features to let people know that the construct is
subject to change and users should not rely on this unless they are
willing to rewrite the uses of this feature later. However, in compiler
generated code everything should be fair game, we will update the
compiler when these features change. This is a requirement to be able to
turn safe wrapper generation on by default.
2025-03-11 17:38:53 +00:00
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Rintaro Ishizaki
ff6cb11bb0 [ASTGen] Introduce 'AvailableAttr::createUnavailableInEmbedded()' 2025-03-07 04:14:50 -08:00
Allan Shortlidge
b64df7384e AST: Simplify AvailabilityRange construction.
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
2025-03-04 19:41:04 -08:00
Allan Shortlidge
b0afd07e14 AST/Parse: Always delay AvailabilityDomain lookup to type-checking.
This will unblock parsing and type-checking availability queries that specify
custom availability domains, e.g.:

```
if #available(CustomDomain) {
  // Use declarations protected by @available(CustomDomain)
}
```
2025-02-26 21:46:14 -08:00
Allan Shortlidge
9c9ba6805a Parse/Sema: Fix diagnostics for missing wildcards in @available.
The previous algorithm failed to correctly handle the cases where some grouped
`@available` attributes could be marked invalid prior to type checking
attributes.
2025-02-25 19:45:39 -08:00
Allan Shortlidge
db29a1c6f4 Parse/Sema: Move #available query wildcard diagnostics to Sema.
In order to unblock resolution of availability domains during type-checking
instead of parsing, diagnostics about missing or superfluous wildcards in
availability specification lists need to move to Sema.
2025-02-23 22:09:33 -08:00
Allan Shortlidge
eb6506a1ad AST: Introduce SemanticAvailabilitySpec.
It wraps an type-checked `AvailabilitySpec`, which guarantees that the spec has
a valid `AvailabilityDomain` associated with it. This will unblock moving
AvailabilitySpec domain resolution from parsing to sema.
2025-02-23 10:53:06 -08:00
Pavel Yaskevich
dd1be8f6d4 [Frontend] Hide @execution attribute behind an experimental feature ExecutionAttribute
Since the proposal has not been approved yet we cannot expose
`@execution` attribute.
2025-02-20 00:05:03 -08:00
Allan Shortlidge
7492e961dc Merge pull request #79494 from tshortli/type-check-availability-spec
Parse/Sema: Move some `AvailabilitySpec` diagnostics from Parse to Sema
2025-02-19 17:07:24 -08:00
Allan Shortlidge
e90530990a Parse/Sema: Move some AvailabilitySpec diagnostics from Parse to Sema.
Eventually, querying the `AvailabilityDomain` associated with an
`AvailabilitySpec` will require invoking a request that takes a `DeclContext`.
This means that any diagnostics related to the domain identified by an
`AvailabilitySpec` need to be emitted during type-checking rather than parsing.
This change migrates several `AvailabilitySpec` diagnostics from Parse to Sema
to unblock further work.
2025-02-19 11:40:56 -08:00
Rintaro Ishizaki
6980509f8c [ASTGen] Generate DefaultArgumentInitializer
Rework ParamDecl contextualization.
2025-02-18 11:13:39 -08:00
Becca Royal-Gordon
5c28f1d73d Merge pull request #78313 from beccadax/llvm_reachable 2025-02-18 01:04:55 -08:00
Rintaro Ishizaki
b729746629 [AST] Make LifetimeDescriptor hold Identifier instead of StringRef
No reason to keep the name as a StringRef
2025-02-17 08:59:18 -08:00
Joe Groff
f778170cfb Merge pull request #79351 from jckarter/lifetime-dependence-lowering
SIL: Lower lifetime dependencies when lowering function types.
2025-02-17 07:51:20 -08:00
Hamish Knight
d11f7c9ed6 Merge pull request #79422 from hamishknight/remove-init-ty
[AST] NFC: Remove `InitRetType`
2025-02-17 00:56:12 +00:00
Hamish Knight
1e8dc55b7f [AST] NFC: Remove InitRetType
This is no longer used.
2025-02-16 18:52:23 +00:00
Rintaro Ishizaki
6184367492 [Parse] Post-process parsed AST to register decls with opaque result
Move the logic out of `Paser` so `ASTGen` can use it.
2025-02-14 18:51:22 -08:00
Joe Groff
c65475628f SIL: Lower lifetime dependencies when lowering function types.
Map the lifetime dependencies described in terms of the formal AST-level parameters
to the correct parameter(s) in the lowered SIL function type. There can be 0, 1,
or many SIL parameters per formal parameter because of tuple exploding. Also,
record which dependencies are on addressable parameters (meaning that the dependency
includes not only the value of the parameter, but its specific memory location).
2025-02-14 09:47:53 -08:00
Allan Shortlidge
06030d66aa AST: Introduce AvailabilityDomainOrIdentifier.
It provides a common way to represent either a parsed domain identifier or the
resolved domain.

NFC.
2025-02-13 21:18:05 -08:00
Allan Shortlidge
670084a9ac AST: Retire PlatformVersionConstraintAvailabilitySpec. 2025-02-12 22:46:58 -08:00
Allan Shortlidge
09f8622b1b AST: Simplify AvailabilitySpec subclasses further.
Remove methods that are specific to AvailabilitySpec subclasses and replace
them with methods on the superclass if necessary.

NFC.
2025-02-11 22:45:43 -08:00
Allan Shortlidge
6daea78ccf AST: Remove AvailabilitySpec.h include from Stmt.h.
Include it where it's actually used instead to improve compile times.
2025-02-11 20:03:01 -08:00
Rintaro Ishizaki
1c1570b5f6 Merge pull request #79203 from rintaro/astgen-miscavailableattr
[ASTGen] Generate miscellaneous availability related nodes
2025-02-07 20:14:17 -08:00
Rintaro Ishizaki
c56dd2efca [ASTGen] Generate miscellaneous availability related nodes
* `@_specialize` with `availability:` arguments
* `@backDeployed` attributes
* `@_originallyDefinedIn` attributes
* `#available()` and `#unavailable()` statement conditions
2025-02-07 10:01:07 -08:00
Michael Gottesman
d33371a51a Merge pull request #79178 from xedin/execution-attr-in-type-context
[AST/Parse] Initial implementation of `@execution(concurrent | caller)` in type context
2025-02-06 18:44:00 -08:00
Pavel Yaskevich
84fb4967cb [Parse] Add parsing for @execution(concurrent | caller) attribute in type context 2025-02-05 00:20:58 -08:00
Rintaro Ishizaki
df2ada37df [ASTGen] Generate AvailableAttr
* Move `AvailabilitySpec` handling logic to AST, so they can be shared
  between libParse and ASTGen
* Requestify '-define-availability' arguments parsing and parse them
  with 'SwiftParser' according to the 'ParserASTGen' feature flag
* Implement 'AvailableAttr' generation in ASTGen
2025-02-04 23:40:01 -08:00
Allan Shortlidge
427c8affef Parse/Sema: Consolidate diagnostics for unexpected versions.
Since resolving the domain of an `@available` attribute is done during type
checking now, diagnostics about unexpected versions for a domain need to be
emitted at that point instead of during parsing. It doesn't make sense to
maintain the special version of this diagnostic that is emitted during parsing
for the universal availability domain only.
2025-02-02 09:57:43 -08:00
Allan Shortlidge
4d2a1ba479 Parse: Accept @available(DomainName).
For now `-enable-experimental-feature CustomAvailability` is required to accept
this spelling, though.
2025-01-28 13:47:42 -08:00
Allan Shortlidge
1284001e45 Sema: Canonicalize platform versions in SemanticAvailableAttrRequest.
This should really be done on-demand during version remapping, but for now the
goal of this change is to be as NFC as possible.
2025-01-26 13:50:56 -08:00
Allan Shortlidge
bd79424039 Sema: Move domain-specific @available attr diagnostics to type checking.
Since the domain is now resolved by SemanticAvailableAttrRequest, diagnosing
attributes with invalid combinations of fields for a specific domains needs to
be delayed.
2025-01-26 13:50:56 -08:00
Allan Shortlidge
a5d60ce35e AST/Sema: Resolve AvailabilityDomain in SemanticAvailableAttrRequest.
Look up the AvailabilityDomain given its name during type checking, instead of
parsing.
2025-01-26 13:50:56 -08:00
Allan Shortlidge
7b8cbd7109 AST: Store unresolved domain strings in AvailableAttr.
This is the first step towards resolving the AvailabilityDomain associated with
an AvailableAttr during type checking instead of parsing.
2025-01-26 13:50:56 -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
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