Commit Graph

6321 Commits

Author SHA1 Message Date
swift-ci
ddbe38ec7b Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 09:38:05 -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
swift-ci
72e3d66404 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-23 15:35:20 -07:00
Kavon Farvardin
54643c1c1d [Parser] allow ~Copyable to appear in more places
With `NoncopyableGenerics` enabled, we want to permit the syntax
`any ~Copyable`, and `~Copyable` generally anywhere a type can be
written. We also want to give proper error messages and deal with
typealiases of `Copyable` correctly when `~` precedes some token other
than `Copyable`.

This patch defines the `~` operator to attach rather tightly to simple
types like identifier-like types. The precedence order is roughly like
this within the syntax of types, from higher to lower:

1. `.` (member lookup)
2. postfix optionals: `?`, `!`
3. inverse `~`
4. postfix `...`, etc.

It's also invalid to write something like `~ any T`, as we'll treat
`any` as if it were a type identifier. You must parenthesize such types
to say `~(any T)`. Similarly, we parse `~T.Type` as `~(T.Type)` and not
`(~T).Type`. That might be controversial, but I don't think inverses
can ever support metatypes; they're not even "real" types.

rdar://115913356
2023-09-22 17:04:57 -07:00
swift-ci
6637cc5a27 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-21 12:13:50 -07: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
swift-ci
f316c11bd3 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-16 08:12:44 -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
swift-ci
93417e9a65 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-12 21:58:10 -07:00
Doug Gregor
131494d2f7 Merge pull request #68475 from DougGregor/anonymous-closure-arg-refs-in-macros 2023-09-12 21:34:51 -07:00
Doug Gregor
06bcd0641f Fix handling of anonymous closure arguments within macro expansions
We were incorrectly emitting a nonsensical error.

Fixes rdar://114340542.
2023-09-12 15:57:03 -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
6293332cba ASTGen: Translate default arguments 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
swift-ci
1363f59915 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-12 03:54:25 -07: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
swift-ci
76f9337f89 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 13:13:44 -07:00
Alex Hoppen
acc6c10344 Merge pull request #68075 from ahoppen/ahoppen/labeled-trailing-closure-solver-based
[CodeCompletion] Migrate labeled trailing closure completions to solver-based
2023-09-06 13:10:56 -07:00
swift-ci
225162a30f Merge remote-tracking branch 'origin/main' into rebranch 2023-09-01 14:36:50 -07:00
Hamish Knight
6ee44f09b4 Introduce then statements
These allow multi-statement `if`/`switch` expression
branches that can produce a value at the end by
saying `then <expr>`. This is gated behind
`-enable-experimental-feature ThenStatements`
pending evolution discussion.
2023-09-01 14:32:14 +01:00
swift-ci
978cdd352a Merge remote-tracking branch 'origin/main' into rebranch 2023-08-30 11:14:10 -07:00
Alex Hoppen
a1bfb510e1 [CodeCompletion] Migrate labeled trailing closure completions to solver-based
rdar://113472967
2023-08-24 15:41:36 -07:00
Alex Hoppen
5d201131c1 [CodeCompletion] Migrate yield completions to solver-based
We didn’t actually have any tests for this. Completions aren’t great here at the moment but since this is an underscored language feature it’s not that important at the moment.
2023-08-23 13:07:56 -07:00
swift-ci
55c9624b36 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-23 04:54:21 -07:00
Luciano Almeida
4c24384f5f [Parse] Remove initializes and accesses attr parse code 2023-08-22 20:55:30 -03:00
swift-ci
39a858cdd1 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-14 17:54:25 -07:00
Kavon Farvardin
4e7e6f41cb remove support for _forget, the old spelling of discard
resolves rdar://112549258
2023-08-11 15:42:25 -07:00
swift-ci
5dc6d1bb72 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 02:55:46 -07: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
Evan Wilde
b98e65a7d0 Fix more optional API changes
Another one slipped past. Fixing the optional API usage.
2023-08-08 22:08:47 -07:00
swift-ci
91ca12528b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-01 15:58:54 -07:00
Pavel Yaskevich
2a0651e8b0 [Frontend/NFC] SE-0400: Enable InitAccessors feature by default 2023-07-31 13:18:59 -07:00
swift-ci
20e81af228 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-31 09:13:49 -07:00
Ben Barham
e103565577 [rebranch] Fix up API update in the lexer
This should have been `countl_one` (leading ones) rather than
`countl_zero` (leading zeroes).
2023-07-29 10:39:00 -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
swift-ci
e1d21fe05c Merge remote-tracking branch 'origin/main' into rebranch 2023-07-27 16:56:57 -07:00
Allan Shortlidge
f9a93a55d7 NFC: Fix duplicate definition of macro warnings.
Centralize the `SWIFT_{BEGIN/END}_NULLABILITY_ANNOTATIONS` definitions in a new
Nullability.h header to share.
2023-07-27 13:02:22 -07:00
Allan Shortlidge
48d5bd836e NFC: Fix unused variable warnings in ParseDecl.cpp. 2023-07-27 12:45:28 -07:00
swift-ci
1969199a8e Merge remote-tracking branch 'origin/main' into rebranch 2023-07-26 23:13:08 -07:00
Joe Groff
705e317c3f Merge pull request #67425 from jckarter/raw-storage
[WIP] Raw storage and locks/atomics prototype
2023-07-26 08:49:02 -07:00
Evan Wilde
fd156f2717 More APInt API updates
Updating more APInt and bit-manipulation API changes.
2023-07-25 12:28:27 -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
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Pavel Yaskevich
4f9a35ed10 Merge pull request #67228 from xedin/diag-init-accessor-without-getter
[Parse] InitAccessors: Diagnose an attempt to use init accessor witho…
2023-07-13 09:34:03 -07:00
Rintaro Ishizaki
2b13365f0b Merge pull request #67206 from rintaro/parse-each-self-rdar107450487
[Parse] Accept 'self' after 'each'
2023-07-11 15:02:26 -07:00