Commit Graph

583 Commits

Author SHA1 Message Date
Steven Wu
dfd11cfec4 [DepScan] Add missing field in JSON output
SwiftSourceModule can contain "commandLine" field and add that into the
JSON output format.
2023-06-30 09:09:27 -07:00
Doug Gregor
4b1a1e7b80 Merge pull request #66889 from DougGregor/init-accessor-stop-escaping-init
[ASTPrinter] Stop unnecessary escaping of `init` in macro role attributes
2023-06-23 12:43:42 -07:00
Doug Gregor
9606a9acfd [ASTPrinter] Stop unnecessary escaping of init in macro role attributes.
The excessive escaping of `init` in macro role attributes was a
workaround paired with https://github.com/apple/swift/pull/65442 to
smooth things over when working across Swift compiler versions.
However, it's causing problems for init accessors, so stop escaping.

Fixes rdar://111190084.
2023-06-23 10:18:26 -07:00
Michael Gottesman
d0938a906f [move-only] Ban resilient noncopyable types.
One can still in resilient frameworks have noncopyable frozen types.

This means that one cannot make a noncopyable:

1. Full resilient public type.
2. @usableFromInline type.

NOTE: One can still use a frozen noncopyable type as a usableFromInline class
field. I validated in the attached tests that we get the correct code
generation.

I also eliminated a small bug in TypeCheckDeclPrimary where we weren't using a
requestified attr check and instead were checking directly.

rdar://111125845
2023-06-21 16:57:44 -07:00
Arnold Schwaighofer
99b5f1b5de Fix directory test/ModuleInterface 2023-06-20 13:15:09 -07:00
Arnold Schwaighofer
5d5dbd98a4 Merge pull request #66077 from aschwaighofer/wip_enable_opaque_pointers
Enable usage of LLVM's opaque pointer
2023-06-15 11:47:24 -07:00
Hamish Knight
3f401fb134 [test] Require asserts for a couple of tests 2023-06-15 12:28:55 +01:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -07:00
Ben Barham
183902da47 Merge pull request #66576 from bnbarham/ignore-host-modules
[Frontend] Ignore adjacent swiftmodule in compiler host modules
2023-06-14 09:38:20 -07:00
Saleem Abdulrasool
545334cf35 Merge pull request #66510 from tristanlabelle/fix-tests-windows-vs2022
Fix tests on Windows CI with VS2022
2023-06-14 08:49:42 -07:00
Ben Barham
ee3a47b624 [Frontend] Ignore adjacent swiftmodule in compiler host modules
`lib/swift/host` contains modules/libraries that are built by the host
compiler. Their `.swiftmodule` will never be able to be read, ignore
them entirely.
2023-06-12 16:53:48 -07:00
Doug Gregor
1209ef89ec Ensure that macros within init accessors are expanded early enough
Now that we've made accessor macro expansion more lazy, ensure that
when querying for init accessors (e.g., to build a memberwise
initializer), we also expand any accessor macros that might produce an
init accessor.

This is a partial step toward the real goal, which is that
`AbstractStorageDecl::getAccessor()` should lazily expand macros if
needed.

Update the Observable macro to document that it produces an `init`
accessor.
2023-06-11 08:48:43 -07:00
Doug Gregor
7fb1ba9798 [AST printer] Stop printing -> () types on all macro declarations. 2023-06-09 23:25:34 -07:00
Tristan Labelle
3c51106fad Fix tests on Windows CI with vs2022 2023-06-09 16:41:05 -04:00
Joe Groff
f06621907e SILGen: Don't copy a borrowed noncopyable address-only base of a computed property access.
We can probably avoid this copy in more circumstances, but make the change only for
noncopyable types for now, since that's the case where it's most semantically apparent.
rdar://109161396
2023-06-08 08:36:04 -07:00
Allan Shortlidge
17d121f7d1 Merge pull request #65954 from tshortli/swiftinterface-inlinable-function-availability-miscompile
Frontend: Don't append `-target-min-inlining-target target` to implicit module builds
2023-05-30 18:10:59 -07:00
Doug Gregor
eeede463fc [Test] Note that test requires observation to be built 2023-05-30 17:31:31 -07:00
Allan Shortlidge
0e7ad1e9a4 Frontend: Don't append -target-min-inlining-target target to implicit module builds.
When performing an implicit module build, the frontend was prepending
`-target-min-inlining-target target` to the command line. This was overriding
the implicit `-target-min-inlining-target min` argument that is implied when
`-library-level api` is specified. As a result, the wrong overload could be
picked when compiling the body of an inlinable function to SIL for emission
into the client, potentially resulting in crashes when the client of the module
is back deployed to an older OS.

Resolves rdar://109336472
2023-05-30 13:33:26 -07:00
Hamish Knight
e03bd0a15d [test] Fully disable moveonly_interface.swift 2023-05-30 09:54:31 +01:00
Dario Rexin
2ea162b9d6 [Test] Use production available features in option-filtering.swift (#66127)
rdar://109832161

Some features used in this test were not available in production compilers, causing build failures.
2023-05-25 22:29:32 -07:00
Doug Gregor
7d0510a1bf Merge pull request #66131 from DougGregor/interfaces-without-macros 2023-05-25 21:07:12 -07:00
Doug Gregor
548ff3a0b2 [Test] Ensure that a class using the Observable macro builds a proper interface 2023-05-25 13:59:41 -07:00
Dario Rexin
670f5d2457 [Test] Improve interface option filter test (#66102) 2023-05-24 15:29:48 -07:00
Dario Rexin
2bb08e37f6 [ModuleInterface] Add mechanism to exclude experimental flags from th… (#66088)
* [ModuleInterface] Add mechanism to exclude experimental flags from the module interface

rdar://109722548

* Separate filtered flags from the typical/unfiltered case
2023-05-24 09:03:01 -07:00
Tristan Labelle
d0ba4ced4b tests: Fix module loading prefer-serialized test failure on Windows
Fixes three tests failing on Windows:

```
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift
  Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode.swift
```

These test cases remove read access to the `.swiftmodule` . The expected
behavior is that the compiler checks `fs.exists("path-to.swiftmodule")`
, determines that the file exists and chooses to use it instead of the
`.swiftinterface`. Compilation then fails because the file cannot be
read.

e22cf2e993/lib/Frontend/ModuleInterfaceLoader.cpp (L752)

On Windows, we were denying `R` access, which is broader than only read
access to file contents but also includes file attributes and
permissions. This caused `fs.exists` to fail since it relies on
`fs.status`, which could not open the file with `CreateFileW`. The fix
is is to only deny `RD - read data/list directory` access.
2023-05-16 14:56:40 -07:00
Slava Pestov
e9e6a51c82 Unconditionally enable variadic generic types now that SE-0398 has been accepted 2023-05-15 23:32:52 -04:00
Slava Pestov
4318a36be6 Sema: Availability checking for variadic generic types 2023-05-12 22:50:25 -04:00
nate-chandler
4d8dab00f8 Merge pull request #65845 from nate-chandler/eagermove_language_feature
[AST] Added language feature for @_eagerMove.
2023-05-11 08:31:25 -07:00
Nate Chandler
b72395814b [AST] Added language feature for @_eagerMove.
The new LexicalLifetimes suppressible language feature results in
declarations annotated with @_eagerMove, @_noEagerMove, and
@_lexicalLifetimes to be printed with that attribute when it's available
and without it when it's not.
2023-05-10 18:19:49 -07:00
Kavon Farvardin
511eb44025 Merge pull request #65787 from kavon/forget-to-discard
rename `_forget` to `discard`; deprecate `_forget`
2023-05-09 07:30:49 -07:00
Kavon Farvardin
3e4bc82aa8 rename _forget to discard; deprecate _forget
SE-390 concluded with choosing the keyword discard rather than forget for
the statement that disables the deinit of a noncopyable type. This commit
adds parsing support for `discard self` and adds a deprecation warning for
`_forget self`.

rdar://108859077
2023-05-08 21:42:19 -07:00
Allan Shortlidge
4a84ddb230 AST: Print official spelling of @backDeployed attr in swiftinterfaces.
It's no longer necessary to support compilers that only parse the
`@_backDeploy` spelling.

Resolves rdar://104920183
2023-05-08 13:56:52 -07:00
Allan Shortlidge
020987a567 Macros: Escape init when printing names for attached macros.
Older compilers can't parse `name(init)`. Restore the call to
`escapeKeywordInContext()` to ensure special names get escaped.

Resolves rdar://108806697
2023-05-02 17:43:04 -07:00
Allan Shortlidge
949612553a Merge pull request #65568 from tshortli/expression-attr-condfail
Revert #64269
2023-05-02 13:13:52 -07:00
Allan Shortlidge
dd5b934a41 Tests: Small updates to ModuleInterface/macros.swift test. 2023-05-01 19:44:57 -07:00
Allan Shortlidge
ffaa1d5dbc Revert "[Macros] Treat FreestandingExpressionMacros as a suppressible feature"
This reverts commit b412c6c884.

Resolves rdar://108591384
2023-05-01 19:44:39 -07:00
Kavon Farvardin
ee819c80a9 Build support for ~Copyable atop @_moveOnly
We parse `~Copyable` in an inheritance clause of enum and
struct decls as a synonym for the `@_moveOnly` attribute
being added to that decl. This completely side-steps the
additional infrastructure for generalized suppressed
conformances in favor of a minimal solution. One benefit of
this minimal solution is that it doesn't risk introducing
any back-compat issues with older compilers or stdlibs.

The trade-off is that we're more committed to supporting
`@_moveOnly` in compiled modules in the future. In fact,
this change does not deprecate `@_moveOnly` in any way.

resolves rdar://106775103
2023-05-01 14:36:39 -07:00
Allan Shortlidge
0e9b8a1e0a Sema: Relax distributed actor typechecking for swiftinterfaces.
Some decls that are expected to be synthesized for distributed actors are
printed explicitly in swiftinterfaces so diagnostics and assertions need to
take that possibility into account.

Resolves rdar://108533918
2023-04-26 08:44:44 -07:00
Doug Gregor
ae4a5ded8f [Macros] Improve parsing, representation, and serialization of role attributes
Parse compound and special names in the macro role attributes
(`@freestanding` and `@attached`). This allows both compound names and
initializers, e.g., `init(coding:)`.

Fixes rdar://107967344.
2023-04-21 11:36:06 -07:00
Slava Pestov
df5d531dc6 ASTPrinter: Fix printing of pack requirements
Also remove the flag for printing 'each' and make it always on.
2023-04-19 13:04:51 -04:00
Allan Shortlidge
8ee6d43876 Merge pull request #65023 from tshortli/exclusivity-attribute-in-swiftinterface
Sema: Skip storage diagnostic for `@exclusivity` in swiftinterfaces
2023-04-10 15:06:48 -07:00
Xi Ge
63e2b2e7b7 ModuleInterface: add a block list action to downgrade module interface verification errors to warnings 2023-04-08 22:15:41 -07:00
Allan Shortlidge
7ba9601e64 Sema: Skip storage diagnostic for @exclusivity in swiftinterfaces.
Relax the diagnostics for the `@exclusivity` attribute in order to avoid type
checking failures for `public private(set)` properties in resilient libraries.
In a `swiftinterface` it's not possible to tell reliably whether a property has
storage.

Resolves rdar://107770440
2023-04-07 21:23:27 -07:00
Slava Pestov
093fa282b0 Guard usage of variadic generics with $ParameterPacks in module interface files
Fixes rdar://107559541.
2023-04-03 19:49:39 -04:00
Saleem Abdulrasool
deed57cefe Merge pull request #64721 from tristanlabelle/fix-lit-python-test-failure-backslash
Fix test failure on Windows due to path separators being treated as escapes
2023-03-31 11:29:27 -07:00
Doug Gregor
7c7459ac6b Merge pull request #64641 from DougGregor/macro-replacement-expansion 2023-03-29 20:47:30 -07:00
Doug Gregor
68b367b266 Disable macros-related tests harder 2023-03-29 16:32:32 -07:00
Doug Gregor
30f17940f9 Require the Swift swift parser for a few tests affected by macros 2023-03-29 16:32:32 -07:00
Doug Gregor
cfbdae586d [Macros] Add a test ensuring that we print expanded macro definitions
This should complete the implementation of expanded macro
definitions, rdar://104044325.
2023-03-29 16:32:32 -07:00
Allan Shortlidge
f4b79594a8 Tests: Fix and re-enable @_spi_available tests
The main issue was that the tests specified `-library-level=api` in
`swift-frontend` invocations instead of `-library-level api`. The former seems
to have no effect and therefore expected diagnostics were not being emitted.

Additional clean up:
- Make every test require `OS=macosx` for ease of local testing.
- Avoid unnecessarily specifying target arches (this makes tests slow).
- Add missing `FileCheck` invocation.
- Add some missing test coverage.

Resolves rdar://91325474
2023-03-29 14:45:22 -07:00