Commit Graph

1131 Commits

Author SHA1 Message Date
Ben Barham
6269643b4d [Index] Prevent re-indexing system modules repeatedly
If a module was first read using the adjacent swiftmodule and then
reloaded using the swiftinterface, we would do an up to date check on
the adjacent module but write out the unit using the swiftinterface.
This would cause the same modules to be indexed repeatedly for the first
invocation using a new SDK. On the next run we would instead raad the
swiftmodule from the cache and thus the out of date check would match
up.

The impact of this varies depending on the size of the module graph in
the initial compilation and the number of jobs started at the same time.
Each SDK dependency is re-indexed *and* reloaded, which is a drain on
both CPU and memory. Thus, if many jobs are initially started and
they're all going down this path, it can cause the system to run out of
memory very quickly.

Resolves rdar://103119964.
2023-02-09 11:49:13 -08:00
Pavel Yaskevich
8eebb5bec1 Merge pull request #63522 from xedin/revert-type-wrappers
[AST/Sema/SIL] Revert TypeWrappers feature functionality
2023-02-09 09:27:18 -08:00
Doug Gregor
85ba74b812 Introduce a separate feature to cover @freestanding(expression) 2023-02-08 11:26:14 -08:00
Pavel Yaskevich
5dded3da73 [Tests] NFC: Remove test-cases associated with TypeWrappers feature 2023-02-08 10:14:34 -08:00
Allan Shortlidge
022abe4d3b NFC: Update tests to use accepted spelling for @backDeployed. 2023-02-01 22:04:33 -08:00
Allan Shortlidge
df1750d8b7 NFC: Rename files containing tests for the @backDeployed attribute to match the approved spelling. 2023-02-01 22:04:33 -08:00
Pavel Yaskevich
7a81eb3810 Merge pull request #63274 from xedin/runtime-metadata-impl-alignment
[AST/Sema] RuntimeMetadata: Align implementation with proposal
2023-02-01 12:37:24 -08:00
Allan Shortlidge
11a55ec3a0 ModuleInterface: Coallesce @_backDeploy attributes when printed.
This should improve the readability of declarations with `@_backDeploy` attributes for multiple platforms.

Resolves rdar://104712811
2023-01-31 13:59:22 -08:00
Pavel Yaskevich
a6a726e1fb [Sema] RuntimeMetadata: Make sure that attrs on unavailable extensions always have a type 2023-01-30 21:03:07 -08:00
Pavel Yaskevich
67b74a0633 [Sema] RuntimeMetadata: Diagnose missing explicit reflection metadata attributes
Diagnose situations where a sub-class or a protocol do not have all
of the reflection metadata attributes required by a superclass.

Resolves: rdar://103990788
2023-01-30 14:14:47 -08:00
Alexis Laferrière
c285c5e2ef [ModuleInterface] Improve swift-export-as test to use the swiftinterfaces 2023-01-27 11:37:47 -08:00
Alexis Laferrière
39fb1c5f55 [ModuleInterface] Intro export-as for Swift modules
Introduce a new flag `-export-as` to specify a name used to identify the
target module in swiftinterfaces. This provides an analoguous feature
for Swift module as Clang's `export_as` feature.

In practice it should be used when a lower level module `MyKitCore` is
desired to be shown publicly as a downstream module `MyKit`. This should
be used in conjunction with `@_exported import MyKitCore` from `MyKit`
that allows clients to refer to all services as being part of `MyKit`,
while the new `-export-as MyKit` from `MyKitCore` will ensure that the
clients swiftinterfaces also use the `MyKit` name for all services.

In the current implementation, the export-as name is used in the
module's clients and not in the declarer's swiftinterface (e.g.
`MyKitCore`'s swiftinterface still uses the `MyKitCore` module name).
This way the module swiftinterface can be verified. In the future, we
may want a similar behavior for other modules in between `MyKitCore` and
`MyKit` as verifying a swiftinterface referencing `MyKit` without it
being imported would fail.

rdar://103888618
2023-01-26 14:27:31 -08:00
Doug Gregor
5a9a654adb Adopt @freestanding(expression) for all @expression macros 2023-01-25 17:07:38 -08:00
Alexis Laferrière
595654492b Merge pull request #63176 from xymus/ambiguous-fixes
[ModuleInterface] Don't alias the stdlib or builtin modules in alias module names mode
2023-01-24 08:27:34 -08:00
Allan Shortlidge
6f721ae8e0 Sema: Avoid diagnosing over-availability in swiftinterfaces.
Resolves rdar://104576016
2023-01-23 18:33:25 -08:00
Alexis Laferrière
c8ca517e56 [ModuleInterface] Don't alias the stdlib or builtin module
Not aliasing the stdlib should allows it to be used in inlinable code.
Since builtin isn't imported explicitly, references to it shouldn't use
the alias.

rdar://104582241
2023-01-23 17:52:37 -08:00
Alexis Laferrière
32d4edad22 [ModuleInterface] Don't alias @_spiOnly imports in public swiftinterfaces 2023-01-23 17:41:11 -08:00
Doug Gregor
43cadcad3a [Macros] Serialization and printing for @attached. 2023-01-14 21:48:43 -08:00
John McCall
55b72d4eb7 Fix the pretty-printing of pack expansion types to match the current design 2023-01-11 03:11:30 -05:00
Holly Borla
6725f365ba [Variadic Generics] Update tests for syntax changes. 2023-01-07 09:50:14 -08:00
Allan Shortlidge
8e46b76882 NFC: Update @_backDeploy tests to remove @available attributes where possible. 2023-01-06 08:18:00 -08:00
Pavel Yaskevich
0987eff828 [Sema] TypeWrappers: Availability of init(storageWrapper:) should match that of $Storage 2023-01-04 16:04:28 -08:00
Doug Gregor
7000969f14 Introduce and use #externalMacro for externally-defined macros.
Align the grammar of macro declarations with SE-0382, so that macro
definitions are parsed as an expression. External macro definitions
are referenced via a referenced to the macro `#externalMacro`. Define
that macro in the standard library, and recognize uses of it as the
definition of other macros to use externally-defined macros. For
example, this means that the "stringify" macro used in a lot of
examples is now defined as something like this:

    @expression macro stringify<T>(_ value: T) -> (T, String) =
        #externalMacro(module: "MyMacros", type: "StringifyMacro")

We still parse the old "A.B" syntax for two reasons. First, it's
helpful to anyone who has existing code using the prior syntax, so they
get a warning + Fix-It to rewrite to the new syntax. Second, we use it
to define builtin macros like `externalMacro` itself, which looks like this:

    @expression
    public macro externalMacro<T>(module: String, type: String) -> T =
        Builtin.ExternalMacro

This uses the same virtual `Builtin` module as other library builtins,
and we can expand it to handle other builtin macro implementations
(such as #line) over time.
2023-01-02 21:22:05 -08:00
Doug Gregor
6bb9cb8b5d [Macros] Always parse macro expansions, diagnose later
Always parse macro expansions, regardless of language mode, and
eliminate the fallback path for very, very, very old object literals
like `#Color`. Instead, check for the feature flag for macro
declaration and at macro expansion time, since this is a semantic
restriction.

While here, refactor things so the vast majority of the macro-handling
logic still applies even if the Swift Swift parser is disabled. Only
attempts to expand the macro will fail. This allows us to enable the
macro-diagnostics test everywhere.
2023-01-02 21:22:04 -08:00
Doug Gregor
f78f5729c3 Start requiring expression macros to be marked with @expression 2022-12-22 09:18:05 -08:00
Erik Eckstein
21b4004d69 Devirtualizer: don't de-virtualize witness calls to non-generic thunks which call a generic function.
If the callee is a non-generic thunk which calls a (not inlinable) generic function in the defining module,
it's more efficient to not devirtualize, but call the non-generic thunk - even though it's done through the witness table.
Example:
```
  protocol P {
    func f(x: [Int])   // not generic
  }
  struct S: P {
    func f(x: some RandomAccessCollection<Int>) { ... } // generic
  }
```

In the defining module, the generic conformance can be fully specialized (which is not possible in the client module, because it's not inlinable).

rdar://102623022
2022-12-21 08:52:53 +01:00
swift-ci
6ccb39009d Merge pull request #62688 from adrian-prantl/102367872-1
Ensure unique names in ParameterList::clone()
2022-12-19 16:32:08 -08:00
Adrian Prantl
9e22b70cff Ensure unique names in ParameterList::clone()
IRGenDebugInfo assumes that all argument names within the same scope are unique
as it uses them as a key in a hash table.

rdar://102367872
2022-12-19 09:50:08 -08:00
Pavel Yaskevich
4e6e6bd29e [Tests] NFC: Add assertions requirement to a type wrapper test
Resolves: rdar://103452169
2022-12-16 10:34:05 -08:00
Pavel Yaskevich
7b08b30e84 Merge pull request #62586 from xedin/rdar-103270262
[AST/Sema] TypeWrappers: Fix a couple of issues with attribute inference from protocols
2022-12-15 17:49:19 -08:00
Pavel Yaskevich
5c11a4b894 [ASTPrinter] TypeWrappers: print inferred attributes 2022-12-14 17:50:28 -08:00
Doug Gregor
3be6344619 Eliminate dependencies on _SwiftSyntaxMacros having actual macros in it 2022-12-14 16:13:48 -08:00
Pavel Yaskevich
a8d8cf0682 [TypeChecker] TypeWrappers: Set access level for $Storage/$storage based on protocol conformances
If a type conforms to a protocol that has a public `$Storage`/`$storage`
requirement the synthesis should produce a public `$Storage`/`$storage`
implementation as well to match the requirement.

Resolves: rdar://103270262
2022-12-14 12:26:53 -08:00
Alexis Laferrière
ab38752d33 [ModuleInterface] Ignore export_as in private swiftinterface
Introduce a new behavior when printing references to modules with an
`export_as` definition. Use the `export_as` name in the public swiftinterface
and the real module name in the private swiftinterface.

This has some limits but should still be an improvement over the current
behavior. First, the we use the `export_as` names only for references to clang
decls, not Swift decls with an underlying module defining an `export_as`.
Second, we always print the `export_as` name in the public swiftinterface,
even in the original swiftinterface file when the `export_as` target is likely
not know, so that generated swiftinterface is still broken.

This behavior is enabled by the flags `-enable-experimental-feature ModuleInterfaceExportAs`
or the `SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY` env var. We may
consider turning it on by default in the future.

rdar://98532918
2022-12-12 14:58:19 -08:00
Anthony Latsis
d553d0466a Merge pull request #62355 from AnthonyLatsis/sr-no-sr
[NFC] Migrate remnant Jira issue references to GitHub issues
2022-12-04 12:08:25 +03:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Slava Pestov
2ebddf5817 Merge pull request #62180 from slavapestov/printing-variadic-types
Fixes for printing variadic generic types
2022-12-02 16:01:13 -05:00
Slava Pestov
b2285f58d7 ASTPrinter: Fix printing variadic BoundGenericTypes 2022-12-02 11:15:43 -05:00
Evan Wilde
5f9ac391be Requires-asserts macro tests
Macros are an experimental feature, as such are not available on
non-asserts compilers.

Adding requires asserts to remaining experimental macro tests.
 - ModuleInterface/macros.swift
 - Serialization/macros.swift
2022-12-01 11:18:10 -08:00
Doug Gregor
1a124e71d6 [Macros] Implement AST printing and module interface generation for macros 2022-11-28 18:33:10 -08:00
Xi Ge
afbc4a5ffd Merge pull request #62251 from nkcsgexi/allowable-serialization
serialization: encode allowable client names in binary module format
2022-11-28 18:12:43 -08:00
Alexis Laferrière
c266e9dce5 Merge pull request #62185 from xymus/improve-rmodule-loading
Improve `-Rmodule-loading` to show both the path to the source and to the cached file actually loaded
2022-11-28 14:25:15 -08:00
Xi Ge
67bbab7e02 serialization: encode allowable client names in binary module format 2022-11-25 18:43:40 -08:00
Alexis Laferrière
319d49816d [Frontend] -Rmodule-loading shows both source path and cached path 2022-11-18 15:28:16 -08:00
Xi Ge
889c543e7f Merge pull request #62166 from nkcsgexi/allowable-client-flag 2022-11-17 23:13:35 -08:00
Xi Ge
7d6cc1875d Frontend: add module interface flag to specify allowable clients
This new flag should allow module authors to specify allowable client list. This list is printed
in the textual module interface. Diagnostics support can come later.
2022-11-17 20:00:40 -08:00
Alexis Laferrière
888fe84013 Merge pull request #62073 from xymus/module-alias-disambiguate-more
[ModuleInterface] AliasModuleNames workaround support for indirect dependencies and missing imports
2022-11-17 10:33:56 -08:00
Alexis Laferrière
7ae02c02f5 [ModuleInterface] Always use the real name for modules not imported directly
In AliasModuleNames, avoid wrongfully printing aliased names for modules
that were not aliased. This can happen in the case of modules indirectly
imported via a reexport.

rdar://102262019
2022-11-16 10:40:55 -08:00
Artem Chikin
729ad402df [Dependency Scanning] Produce canonical output path for Swift binary modules.
Instead of relying on the client (driver) to perform its own computation of the matching output path.
2022-11-15 11:08:13 -08:00
Artem Chikin
5e208ff30e Merge pull request #62067 from artemcm/DepScanClangOutputPath
[Dependency Scanning] Produce canonical output path for Clang PCMs.
2022-11-15 08:39:04 -08:00