Commit Graph

2437 Commits

Author SHA1 Message Date
Doug Gregor
6e419b6345 Revert "[6.2] Accept @cdecl global functions and enums, behind experimental feature flags" 2025-07-16 10:05:35 -07:00
Alexis Laferrière
c0d0cf5f3d Parser: Reject @cdecl attributes with the string format 2025-07-03 15:08:00 -07:00
Alexis Laferrière
22521548a7 Parser: Accept @cdecl with an indentifier for the C name
Begin accepting the attribute in the form of `@cdecl(cName)`, using an
identifier instead of a string.

For ease of landing this change we still accept the string form. We
should stop accepting it before making this feature available in
production.
2025-07-03 14:11:27 -07:00
Alexis Laferrière
3209730bac Parser: Intro @cdecl attribute and gate it behind feature flag CDecl 2025-07-03 13:45:33 -07:00
Andrew Trick
102e5ecee1 Fix a compiler crash with '@'_lifetime(inout x), add diagnostic
This is a common mistake made more common be suggestions of existing diagnostic
that tell users not to use a 'copy' dependency.

Report a diagnostic error rather than crashing the compiler. Fix the diagnostic
output to make sense relative to the source location.

Fixes rdar://154136015 ([nonescapable] compiler assertion with @_lifetime(x: inout x))

(cherry picked from commit 080b68292d)
2025-06-26 12:58:40 -07:00
Meghana Gupta
58b714b968 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-11 08:03:40 -07:00
Meghana Gupta
a9b831788d Update spelling for representing lifetime dependencies to @_lifetime 2025-06-11 08:03:39 -07:00
Pavel Yaskevich
e5501d485a [AST] NFC: Capitalize UsingSpecifier::nonisolated for consistency
(cherry picked from commit 21ec5924f7)
2025-06-04 13:22:34 -07:00
Pavel Yaskevich
76886eb82b [Diagnostics] Tailor using diagnostic to current use-case - default isolation
(cherry picked from commit ec9132cb5a)
2025-06-04 13:22:34 -07:00
Pavel Yaskevich
d3f8fd8fd7 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature
(cherry picked from commit c246a7a372)
2025-06-04 13:22:32 -07:00
Pavel Yaskevich
89c3b0ba41 [Parse] Implement parsing for using declarations
(cherry picked from commit 4ad27ba61e)
2025-06-04 13:16:55 -07:00
Pavel Yaskevich
e12201769d [AST/Sema/SIL] Implement @_inheritActorContext(always)
- Extend `@_inheritActorContext` attribute to support optional `always` modifier.
  The new modifier will make closure context isolated even if the parameter is not
  captured by the closure.
- Implementation `@_inheritActorContext` attribute validation - it could only be
  used on parameter that have `@Sendable` or `sending` and `@isolated(any)` or
  `async` function type (downgraded to a warning until future major Swift mode
  to avoid source compatibility issues).
- Add a new language feature that guards use of `@_inheritActorContext(always)` in swift interface files
- Update `getLoweredLocalCaptures` to add an entry for isolation parameter implicitly captured by `@_inheritActorContext(always)`
- Update serialization code to store `always` modifier

(cherry picked from commit 04d46760bb)
(cherry picked from commit c050e8f75a)
(cherry picked from commit c0aca5384b)
(cherry picked from commit a4f6d710cf)
(cherry picked from commit 6c911f5d42)
(cherry picked from commit 17b8f7ef12)
2025-05-22 11:32:35 -07:00
Cal Stephens
f4bedbc720 Revert changes to trailing commas in attributes like @available 2025-05-20 15:49:03 -07:00
Cal Stephens
bad48874f0 Add trailing comma support in cases missing from Swift 6.1 2025-05-20 15:48:58 -07:00
Michael Gottesman
e92e9dff0c Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.

(cherry picked from commit 3ff9463957)
2025-05-14 16:07:04 -07:00
Becca Royal-Gordon
31429fc522 [Legacy parser] No freestanding macros in @abi
SwiftSyntaxParser is already doing this, and we already diagnosed it in Sema anyway, so we’re just moving that diagnostic earlier so the ASTGen testing mode is happy. Also adding compiler tests for it.

Macro-related tests are not included in this commit; they require matching swift-syntax changes which are being negotiated.
2025-05-08 18:27:57 -07:00
Rintaro Ishizaki
bd6c04fe20 [Parse] Parse operator function with value generics
Operator function parsing has a heuristics to determine if `<` a part of
the operator name or the generic parameter clause. Handle `let` there
because value generics uses it.

rdar://149556573
(cherry picked from commit 682d2634ba)
2025-05-02 17:38:49 -07:00
Pavel Yaskevich
06f880e65c [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-16 13:18:52 -07:00
Pavel Yaskevich
fde841704c [AST/Parse] Implement nonisolated(nonsending) type modifier 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
d8c64c1ff0 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
4a973f7b4b [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-16 10:06:08 -07:00
Pavel Yaskevich
7c6ec33400 [Parse] Remove warning about @concurrent being alternative to @Sendable 2025-04-16 10:06:08 -07:00
Meghana Gupta
96aeea9f2b Rename ParsedLifetimeDependenceKind::Scope -> ParsedLifetimeDependenceKind::Borrow 2025-04-09 10:18:11 -07:00
Meghana Gupta
91ad1451ce Add support for @lifetime(&arg) 2025-04-09 10:18:11 -07:00
Anthony Latsis
fffa8c2f51 Diag: Abstract away some calls to DeclAttribute::getAttrName 2025-03-28 02:01:27 +00:00
Hamish Knight
42e554ef7d [Parse] Set AttrRange for @nonisolated
Make sure we set the `AttrRange` in cases where `@` is present, but
`unsafe` isn't present.

rdar://147965036
2025-03-27 18:48:55 +00:00
Becca Royal-Gordon
d2276362a4 Support @abi on subscripts
And make sure we reject it on `deinit`s and accessors.
2025-03-26 10:47:57 -07:00
Becca Royal-Gordon
b4d545f873 [NFC] Fix AllowFeatureSuppressionAttr atLoc 2025-03-26 10:47:12 -07:00
Nate Chandler
317a379693 [DefaultOverrides] SIL printing/parsing. 2025-03-25 07:22:14 -07:00
Rintaro Ishizaki
92a6fece48 [ASTGen] ObjC improvements
* Generate `#selector(...)` expression
* Generate `#keyPath(...)` expression
* Implicit `@objc` attribute for `@_objcImplementation` attribute
2025-03-20 05:04:58 -07:00
Joe Groff
24a91bba5d Merge pull request #80038 from jckarter/addressable-for-deps-lowering
SIL: Lower fields that are conditionally addressable because of a dependency.
2025-03-17 21:28:33 -07:00
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