Commit Graph

2357 Commits

Author SHA1 Message Date
Sophia Poirier
f65b157058 corrected implementation of parsing nonisolated(unsafe) as decl contextual keyword in top-level global scope (follow up to 5a8825705) 2023-11-11 11:28:55 -08:00
Meghana Gupta
3db420a45f Merge pull request #69176 from meg-gupta/resultdependson
Add initial support for  _resultDependsOnSelf
2023-11-08 18:55:51 -08:00
Sophia Poirier
5a88257052 Merge pull request #69624 from sophiapoirier/nonisolated-unsafe-globals-temp
parse nonisolated(unsafe) as decl contextual keyword in top-level global scope rather than as function invocation
2023-11-08 07:45:11 -08:00
Meghana Gupta
5658deae27 Add initial support for _resultDependsOnSelf
This is used to establish lifetime dependence between self and the result.

Add under NonEscapableTypes experimental feature
2023-11-08 01:48:59 -08:00
Sophia Poirier
e10504f8f7 parse nonisolated(unsafe) as decl contextual keyword in top-level global scope rather than as function invocation (temporary solution) 2023-11-07 16:15:29 -08:00
Yuta Saito
70a1ac2139 Merge pull request #69683 from kateinoigakukun/katei/underscore-extern
Add underscore prefix to extern attribute
2023-11-07 06:00:27 -05:00
Yuta Saito
79b3d2d626 Add underscore prefix to extern attribute
It's already guarded by a feature flag, but it would be nice to signal
users that it's not stable yet by adding an underscore prefix.
2023-11-07 02:01:02 +00:00
Rintaro Ishizaki
7e27d99075 [Parse] Remove 'Flags' from 'PersistentParserState'
This is not used anymore.
2023-11-02 23:13:59 -07:00
Rintaro Ishizaki
5862d347e6 [Parse] Remove 'ParseDeclOptions' parameter from 'parseDecl' function
'ParseDeclOptions' can be trivially calculated solely from the current
decl context. To reduce the number of the contextual parameters,
calculate it inside the function.
2023-11-02 16:50:33 -07:00
Hamish Knight
6afde8a6d2 Remove CBasicBridging and CASTBridging
Merge with BasicBridging and ASTBridging
respectively. The changes here should be pretty
uncontroversial, I tried to keep it to just moving
code about.
2023-10-30 23:49:56 +00:00
Sophia Poirier
77e7dc2c19 Merge pull request #69280 from sophiapoirier/globals_strict_concurrency_opt_out_nonisolated_unsafe
nonisolated(unsafe) to opt out of strict concurrency static checking for global variables
2023-10-26 22:34:22 -07:00
Sophia Poirier
4c9a726183 nonisolated(unsafe) to opt out of strict concurrency static checking for global variables 2023-10-26 16:22:28 -07:00
Visckmart
e18bfaba52 [Parser] Improve diagnostics for access-level modifiers
Improve the diagnostics for situations where multiple access-level modifiers are used on the same declaration. Keep the original duplicate error message if the access levels are the same.
2023-10-26 19:02:35 -03:00
Yuta Saito
4f0e3bf3ea Merge pull request #69207 from kateinoigakukun/yt/cdecl-without-body
Introduce `@extern(c)` to declare C function without Clang module
2023-10-23 12:48:12 -07:00
Yuta Saito
69479933df [c-interop] Rename @_extern to @extern
Now the feature is gated by experimental feature flag.
It's not shipped in any language release, so this rename should be fine.
2023-10-20 17:37:43 +00:00
Yuta Saito
b62171a2c7 [c-interop] Relax C name validation as warning
And allow expert users to use potentially invalid symbols by specifying
it explicitly.
2023-10-20 15:34:09 +00:00
Yuta Saito
1008ecc293 [c-interop] Use llvm::Optional instead of std::optional for now
The Attr.h is shared with SwiftCompilerSources through C++ interop and
C++ interop somehow crashes with libc++'s std::optional. So use legacy
llvm::Optional for now.
2023-10-20 15:34:09 +00:00
Yuta Saito
b27fd9a616 [c-interop] Add @_extern(c) attribute to declare C function in Swift 2023-10-20 15:34:08 +00:00
Kuba Mracek
25cad6fe8a Diagnose more invalid uses of @_section/@_used 2023-10-18 17:48:20 -07:00
Yuta Saito
bd898b0e7e [wasm] add @_extern(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "import"ed from host environment. It's equivalent of Clang's
`__attribute__((import_module("module"), import_name("field")))`
2023-10-10 22:42:08 +00:00
Karl Wagner
ab4f80ed95 [SE-0404] Allow protocols to be nested in non-generic contexts 2023-10-06 21:04:03 +02:00
Alex Hoppen
90506909d3 Merge pull request #68603 from ahoppen/ahoppen/storage-attribute-completion
[CodeCompletion] Completion for `@storageRestrictions` attribute
2023-10-02 10:17:43 -07:00
Doug Gregor
ef642098f2 [Typed throws] Parsing and AST representation for typed errors
Parse typed throw specifiers as `throws(X)` in every place where there
are effects specified, and record the resulting thrown error type in
the AST except the type system. This includes:
* `FunctionTypeRepr`, for the parsed representation of types
* `AbstractFunctionDecl`, for various function-like declarations
* `ClosureExpr`, for closures
* `ArrowExpr`, for parsing of types within expression context

This also introduces some serialization logic for the thrown error
type of function-like declarations, along with an API to extract the
thrown interface type from one of those declarations, although right
now it will either be `Error` or empty.
2023-09-29 10:51:51 -07:00
Rintaro Ishizaki
8dbde04c61 Merge pull request #68408 from rintaro/fetch-content
[CMake] Replace early swift-syntax with FetchContent
2023-09-28 11:22:10 -07:00
Alex Hoppen
17e6a25234 [Parse] Accumulate a parser status while parsing attributes 2023-09-27 09:33:38 -07:00
Alex Hoppen
ee85314e6f [CodeCompletion] Add completion for @storageRestrictions 2023-09-27 09:33:38 -07:00
Yuta Saito
ac440c336a [wasm] Accept multiple @_expose on a single function decl
But multiple @_expose with the same exposure kind are still invalid.
2023-09-26 14:13:43 +00:00
Yuta Saito
6d378a3ec3 [wasm] add @_expose(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "export"ed from this .wasm module. It's equivalent of Clang's
`__attribute__((export_name("name")))`
2023-09-26 14:13:33 +00:00
Kavon Farvardin
c01360d02e [Sema] reimplement ~C as an general inverse constraint 2023-09-20 09:34:06 -07:00
Ben Barham
041691184c [CMake] Replace early swift-syntax with FetchContent
Use FetchContent to include swift-syntax directly in swift. This can be
thought of as an `add_subdirectory` for a directory outside the root.

The default build directory will be `_deps/swiftsyntax-subbuild/`, though
the modules and shared libraries will be built in `lib/swift/host` by
passing down `SWIFT_HOST_LIBRARIES_DEST_DIR` to avoid copying them as we
were doing previously.
2023-09-18 14:44:10 -07:00
Alex Hoppen
44a4d6998c Merge pull request #67111 from AnthonyLatsis/astgen-decls
ASTGen: An assortment of strides and improvements
2023-09-16 08:08:05 -07:00
Anthony Latsis
b6be6da277 ASTGen: Translate associated type declarations
Plus tweak `DefaultDefinitionTypeRequest` caching to support querying the
cached type when dumping. This fixes a crash where type computation is
triggered in the dumper before import resolution in `-dump-parse` mode.
2023-09-12 20:37:50 +03:00
Anthony Latsis
4b2cdedc48 ASTGen: Start diagnosing instances of an invalid syntax tree 2023-09-12 20:37:50 +03:00
Kuba Mracek
9a380212c1 [embedded] Add an interim attr to mark declarations as unavailable in embedded Swift
Implemented as custom parsing logic instead of a proper attribute because we want it to be rewritten at parse time (into nothing in regular Swift mode, and into unconditional unavailable attr in embedded Swift mode), no serialization, printing, etc.
2023-09-10 08:23:31 -07:00
Luciano Almeida
4c24384f5f [Parse] Remove initializes and accesses attr parse code 2023-08-22 20:55:30 -03:00
Hamish Knight
35a98f3828 [ASTGen] Allow querying of enabled features
For now this is using C interop, we ought to be
using C++ interop, but that's a much bigger
change.
2023-08-09 19:35:50 +01:00
Pavel Yaskevich
2a0651e8b0 [Frontend/NFC] SE-0400: Enable InitAccessors feature by default 2023-07-31 13:18:59 -07:00
Pavel Yaskevich
7777ed5b00 [Parser] NFC: Rename isAllowedInProtocolRequirement -> isAllowedWhenParsingLimitedSyntax 2023-07-28 13:53:03 -07:00
Pavel Yaskevich
1a9c2e63f5 [Parse] InitAccessors: Parse limited representation of init accessor in SIL context 2023-07-28 08:32:37 -07:00
Allan Shortlidge
48d5bd836e NFC: Fix unused variable warnings in ParseDecl.cpp. 2023-07-27 12:45:28 -07:00
Joe Groff
aee071bf4e Introduce an experimental @_rawLayout attribute.
This attribute can be attached to a noncopyable struct to specify that its
storage is raw, meaning the type definition is (with some limitations)
able to do as it pleases with the storage. This provides a basis for
implementing types for things like atomics, locks, and data structures
that use inline storage to store conditionally-initialized values.
The example in `test/Prototypes/UnfairLock.swift` demonstrates the use
of a raw layout type to wrap Darwin's `os_unfair_lock` APIs, allowing
a lock value to be stored inside of classes or other types without
needing a separate allocation, and using the borrow model to enforce
safe access to lock-guarded storage.
2023-07-24 14:28:19 -07:00
Pavel Yaskevich
0bbf3403e4 [Parse] InitAccessors: Diagnose an attempt to use init accessor without a getter 2023-07-11 13:45:38 -07:00
Pavel Yaskevich
4760b95282 Merge pull request #67183 from xedin/convert-effects-into-storageRestrictions
[AST/Sema] Implement @storageRestrictions attribute
2023-07-11 11:57:14 -07:00
Alex Hoppen
ed4dc1becd Change Optional -> llvm::Optional 2023-07-07 21:16:33 +02:00
Alex Hoppen
c385fe5e87 [CodeCompletion] Migrate PostfixExprParen to solver-based 2023-07-07 19:50:46 +02:00
Pavel Yaskevich
9992af593c [Parse] InitAccessors: Implement @storageRestrictions parsing, diagnostics and error recovery 2023-07-07 10:00:36 -07:00
Pavel Yaskevich
9719cd01ef [AST] InitAccessors: Introduce new @storageRestrictions(initializes:accesses:) attribute
This is the replacement for `initializes`, `accesses` attributes.
2023-07-07 10:00:35 -07:00
Doug Gregor
16bfd783f4 [Macros] When a macro defines a getter or setter, remove didSet/willSet
As with the initial value of a property that is converted from a stored
property to a computed property by an accessor macro, remove
didSet/willSet. It is the macro's responsibility to incorporate their
code or diagnose them.

Fixes rdar://111101833.
2023-07-05 19:37:21 -07:00
Doug Gregor
22158be449 [Macros] Diagnose when an accessor macro produces an accessor that already exists
We used to crash; now we diagnose and... don't crash.

Fixes rdar://111588129.
2023-07-05 16:27:25 -07:00
Doug Gregor
6fca08acf7 [Macros] Cope with local types and opaque result types in macros and expansions
Address a few related issues that affect local types and opaque result types within macros:
* Don't add local types or opaque types encountered while parsing the
arguments of a freestanding macro to the global list. When we do add
them, make sure we're adding them to the outermost source file so
they'll get seen later. This avoids trying to generate code for these
types, because they aren't supposed to be part of the program. Note
that a similar problem remains for arguments to attached macros, which
will need to be addressed with a more significant refactoring.
* When determining whether opaque types should be substituted within a
resilience domain, check the outermost source files rather than the exact
source file, otherwise we will end up with a mismatch in
argument-passing conventions.
* When delaying the type checking of functions that occur as part of a
macro expansion, make sure we record them in the outermost Swift source
file. Otherwise, we won't come back to them.

There is a common theme here of using AST state on the source file in
a manner that isn't ideal, and starts to break down with macros. In
these cases, we're relying on side effects from earlier phases
(parsing and type checking) to inform later phases, rather than
properly expressing the dependencies through requests.

Fixes rdar://110674997&110713264.
2023-07-03 15:09:54 -07:00