Commit Graph

2456 Commits

Author SHA1 Message Date
Gabor Horvath
7ac9a81b1e [cxx-interop] Add attribute to hide Swift declarations from interop
This can help work around problems when the names of a C++ declaration
and a Swift declaration would collide, or to temporarily work around
compiler bugs.

rdar://152838988&140802127&158843666
2025-09-01 12:29:34 +01:00
Rintaro Ishizaki
a8fba10da1 [Parse] Ignore '(' on newline after attribute names
Also '#error', '#warning', and '#sourceLocation'.

Other call-like syntax (call expression, macro expansion, and custom
attribtues) requires '(' on the same line as the callee. For consistency,
built-in attributes and built-in directives should also ignore '(' on
next line.
2025-08-24 19:20:33 -07:00
Ahmed Mahmoud
df0eda93f4 [IDE] Update comments for access control missing set fix-its 2025-08-15 15:23:29 +03:00
Ahmed Mahmoud
3cd3c048cf [Diagnostics] Add fix-its for missing set and ) of access modifier 2025-08-10 01:57:02 +03:00
Pavel Yaskevich
43eec8fede [AST/Sema] SE-0487: Expand @nonexhaustive attribute to support warn argument
The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.
2025-07-04 10:20:25 -07:00
Alexis Laferrière
81a0f98783 Merge pull request #82194 from xymus/cdecl-parser
Parser: Accept `@cdecl` with an optional identifier for a custom C name
2025-06-27 15:06:11 -07:00
Andrew Trick
080b68292d 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))
2025-06-25 16:34:43 -07:00
Anthony Latsis
3e9923f0c0 ASTBridging: Bridge swift::AccessorKind directly 2025-06-19 04:26:52 +01:00
Slava Pestov
cfa9de8f0a Parse: Address an llvm_unreachable that is actually reachable 2025-06-17 10:15:30 -04:00
Slava Pestov
908c9368ed Parse: Only accept certain literals as enum case raw values
Just checking for LiteralExpr is too broad, because Sema doesn't
know what to do with RegexLiteralExpr for example.
2025-06-17 09:19:00 -04:00
Alexis Laferrière
2601ff44d4 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-06-11 12:42:38 -07:00
Meghana Gupta
dcf072f9d0 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-07 12:49:07 -07:00
Meghana Gupta
0dfa1fc312 Update spelling for representing lifetime dependencies to @_lifetime 2025-06-07 12:49:07 -07:00
Allan Shortlidge
14341285cb Parse: Fix unused variable warning. 2025-06-03 09:45:46 -07:00
Pavel Yaskevich
21ec5924f7 [AST] NFC: Capitalize UsingSpecifier::nonisolated for consistency 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
ec9132cb5a [Diagnostics] Tailor using diagnostic to current use-case - default isolation 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
c246a7a372 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
4ad27ba61e [Parse] Implement parsing for using declarations 2025-05-31 10:49:45 -07:00
Arnold Schwaighofer
7ac551636b Merge pull request #81714 from aschwaighofer/se0460
SE-0460: Introduce @specialized attribute
2025-05-28 12:03:48 -07:00
Arnold Schwaighofer
13ff5abdb8 Introduce @specialized attribute
Implements SE-0460 -- the non-underscored version of @specialized.

It allows to specify "internal" (not abi affecting) specializations.

rdar://150033316
2025-05-23 13:12:47 -07:00
Rintaro Ishizaki
6f24696878 Merge pull request #81612 from calda/cal--trailing-comma-missing-from-6.1
Add trailing comma support in cases missing from Swift 6.1
2025-05-22 11:30:28 -07:00
Cal Stephens
9072d860d9 Revert changes to trailing commas in attributes like @available 2025-05-19 16:00:42 -07:00
Cal Stephens
1a3d71cc53 Add trailing comma support in cases missing from Swift 6.1 2025-05-19 09:19:49 -07:00
Pavel Yaskevich
04d46760bb [AST] Extend @_inheritActorContext attribute to support optional always modifier
By default (currently) the closure passed to a parameter with `@_inheritActorContext`
would only inherit isolation from `nonisolated`, global actor isolated or actor
context when "self" is captured by the closure. `always` changes this behavior to
always inherit actor isolation from context regardless of whether it's captured
or not.
2025-05-14 20:07:57 -07:00
Hamish Knight
e0ceb85c6a [AST] Remove unparsed case from FuncDecl::getSourceRange
This wasn't really sound since it could result in source ranges that
have different buffers for the start and end loc. Instead, adjust
the parser logic to look at the brace range.
2025-05-14 11:15:42 +01:00
Rintaro Ishizaki
682d2634ba [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
2025-05-02 17:09:13 -07:00
Becca Royal-Gordon
25bf069ce3 [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-04-18 14:50:01 -07:00
Alexis Laferrière
a6beaf8deb Merge branch 'main' into cdecl-global-function-checking 2025-04-16 11:19:37 -07:00
Pavel Yaskevich
07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
54b62ae983 [AST/Parse] Implement nonisolated(nonsending) type modifier 2025-04-11 15:59:25 -07:00
Pavel Yaskevich
b1ffa063b6 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-11 15:57:11 -07:00
Pavel Yaskevich
4b8c8e7d72 [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-11 12:08:29 -07:00
Pavel Yaskevich
e3cbdaa863 [Parse] Remove warning about @concurrent being alternative to @Sendable 2025-04-11 12:08:29 -07:00
Alexis Laferrière
02b5998536 Parser: Intro @cdecl attribute and gate it behind feature flag CDecl 2025-04-11 11:34:39 -07:00
Michael Gottesman
77a86a525b Merge pull request #79891 from gottesmm/pr-9df6772bb44656cbd85cad72ee5c3637caab8956
Make Feature a struct enum so we can put methods on it.
2025-04-07 10:32:23 -07:00
Meghana Gupta
2d9217bb4f Merge pull request #80541 from meg-gupta/inoutreland
Reland #80452
2025-04-07 10:20:10 -07:00
Anthony Latsis
3c3dd54f39 AST: Cut down on DescriptiveDeclKind usage in DiagnosticsParse.def 2025-04-05 12:31:20 +01:00
Michael Gottesman
3ff9463957 Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.
2025-04-05 10:08:29 +01:00
Meghana Gupta
ef1e94577f Revert "Merge pull request #80540 from swiftlang/revert-80452-lifetimeinout"
This reverts commit 6eaa07a880, reversing
changes made to e75ee3f4cf.
2025-04-04 09:50:13 -07:00
Artem Chikin
39e1791b67 Revert "Add support for inout lifetime dependence" 2025-04-04 09:00:09 -07:00
Meghana Gupta
d87a2b2ada Rename ParsedLifetimeDependenceKind::Scope -> ParsedLifetimeDependenceKind::Borrow 2025-04-03 17:22:13 -07:00
Meghana Gupta
cfacd25df4 Add support for @lifetime(&arg) 2025-04-03 17:22:06 -07:00
Anthony Latsis
99f63ed933 DiagnosticEngine: Support TypeAttribute diagnostic arguments 2025-04-03 01:52:38 +01: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