Commit Graph

2173 Commits

Author SHA1 Message Date
Hamish Knight
8fdb48d910 [AST] Rename SubscriptDecl::create -> createParsed
And generate the DeclName using the argument labels
on the ParameterList.
2023-12-15 21:44:31 +00:00
Hamish Knight
526dcfbe11 [AST] Factor out AccessorDecl::createParsed
Move the logic for splicing together the
accessor's parameter list out of the parser so
that ASTGen will be able to use it too.
2023-12-15 21:44:30 +00:00
Hamish Knight
e1d35d90aa [AST] Introduce TypedPattern::createPropagated 2023-12-15 21:44:30 +00:00
Hamish Knight
b04d5d5abc [ASTGen] Better handle pattern binding entries
Generate all entries, and ensure we introduce a
PatternBindingInitializer context for non-local
cases. Also use this opportunity to cleanup
`PatternBindingDecl::create`.
2023-12-15 21:44:30 +00:00
Andrew Trick
ace9937e95 Rename NonesapableTypes feature
Follow the feature flag convention for capitalization and be
consistent with the related NoncopyableGenerics feature.

This is a new feature that no wild Swift code has used it yet:

commit e99ce1cc5d
Author: Kavon Farvardin <kfarvardin@apple.com>
Date:   Tue Dec 5 23:25:09 2023

    [NCGenerics] add `~Escapable`

    Basic implementation of `~Escapable` in the type system.
2023-12-14 11:32:03 -08:00
Sophia Poirier
d319404e16 [Concurrency] unguard nonisolated(unsafe) attribute from GlobalConcurrency experimental feature 2023-12-13 15:06:07 -08:00
Hamish Knight
a68c2ac714 [Parse] Restore accidentally deleted code 2023-12-11 12:00:47 +00:00
Hamish Knight
5e7854f46b [AST] Remove static loc and spelling kind from AccessorDecl
The spelling kind was only ever set to
`StaticSpellingKind::None`, and the static location
was never used for anything (and should be queried
on the storage anyway). This doesn't affect the
computation of `isStatic` since `IsStaticRequest`
already takes the static-ness from the storage for
accessors.
2023-12-08 17:59:44 +00:00
Meghana Gupta
b6326f5f24 Add initial support for _resultDependsOn
These attributes are used to establish lifetime dependence between
argument and the result.

Add them under NonEscapableTypes experimental feature
2023-12-06 16:38:38 -08:00
Doug Gregor
36a2dcd927 Implement function body macros
Function body macros allow one to introduce a function body for a
particular function, either providing a body for a function that
doesn't have one, or wholesale replacing the body of a function that
was written with a new one.
2023-11-27 17:04:55 -08:00
Doug Gregor
89bda715ce Merge pull request #69840 from DougGregor/macro-role-metaprogramming
[Macros] Macro-metaprogram macro roles
2023-11-14 11:51:50 -08:00
Doug Gregor
ffa5ba7ce3 More macro metaprogramming for macro roles 2023-11-14 09:20:15 -08:00
Kavon Farvardin
dbd17c538a [NCGenerics] allow feature-guarded uses of ~Copyable
We need to delay the pre-NCGenerics errors about
illegal uses of ~Copyable from Parse until Sema.
Otherwise, such uses can't appear within a false
2023-11-13 15:51:41 -08:00
Kavon Farvardin
b55c4f1fc9 [nfc] allow ErrorTypeRepr to store a ZeroArgDiagnostic
There are sometimes parsing stuations where we don't want to
emit a parsing error, because of feature guarding. For
example, if a Feature involves new syntax for a type, we
must be able to parse both the true and false sides of an
ifdef guarding that new syntax based on a Feature flag.
2023-11-13 15:49:46 -08:00
Sophia Poirier
3d89295736 Merge pull request #69796 from sophiapoirier/nonisolated-unsafe-globals-corrected
corrected implementation of parsing nonisolated(unsafe) as decl contextual keyword in top-level global scope
2023-11-13 14:31:40 -08:00
Rintaro Ishizaki
fb08a92f48 [ASTGen] Infrastructure to implment ASTGen Incrementally
* 'ASTGenVisitor' has a reference to a legacy C++ Parser configured for
  ASTGen.
* If 'ASTGenVisitor' encounters a AST node that hasn't been migrated,
  call parse(Decl|Stmt|Expr|Type) to parse the position using the legacy
  parser.
* The legacy parser calls ASTGen's
  'swift_ASTGen_build(Decl|Stmt|Expr|Type)' for each ASTNode "parsing"
  (unless the call is not directly from the ASTGen.)

rdar://117151886
2023-11-12 21:43:08 -08:00
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