Commit Graph

1673 Commits

Author SHA1 Message Date
Alexis Laferrière
2c508d95b2 [Serialization] Intro the DESERIALIZATION_SAFETY record format
The DESERIALIZATION_SAFETY record will be used by the deserialization
safety feature to identify decls that are unsafe to read so they can be
skipped.
2023-01-06 12:02:47 -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
9e61b01ec1 Rework computation of local discriminators for named entities.
Local discriminators for named entities are currently being set by the
parser, so entities not created by the parser (e.g., that come from
synthesized code) don't get local discriminators. Moreover, there is
no checking to ensure that every named local entity gets a local
discriminator, so some entities would incorrectly get a local
discriminator of 0.

Assign local discriminators as part of setting closure discriminators,
in response to a request asking for the local discriminator, so the
parser does not need to track this information, and all local
declarations---including synthesized ones---get local discriminators.
And add checking to make sure that every entity that needs a local
discriminator gets assigned one.

There are a few interesting cases in here:
* There was a potential mangling collision with local property
wrappers because their generated variables weren't getting local
discriminators
* $interpolation variables introduced for string interpolation weren't
getting local discriminators, they were just wrong.
* "Local rename" when dealing with captures like `[x]` was dependent on
the new delcaration of `x` *not* getting a local discriminator. There
are funny cases involving nesting where it would do the wrong thing.
2022-12-21 15:01:07 -08:00
Ellie Shin
72ee150982 Add -package-name flag
De/serialize package name in module binary
Resoles rdar://103531218, rdar://103531208
2022-12-19 14:33:44 -08:00
Nate Chandler
8d8577e5b0 [SIL] Removed Indirect_In_Constant convention.
It is no different from @in.

Continue parse @in_constant in textual and serialized SIL, but just as
an alias for @in.
2022-12-09 21:54:00 -08:00
Doug Gregor
bbbc346768 [Macros] Treat MacroDecl as a local context, like functions are. 2022-11-28 18:33:10 -08:00
Doug Gregor
1a124e71d6 [Macros] Implement AST printing and module interface generation for macros 2022-11-28 18:33:10 -08:00
Doug Gregor
4ce0834c51 [Macros] Serialization support for macro declarations. 2022-11-28 18:33:09 -08:00
Xi Ge
29504bdd5f Merge branch 'main' into allowable-serialization 2022-11-28 12:36:52 -08:00
Holly Borla
c225fc428b Merge pull request #62228 from hborla/pack-element-generic-environment
[GenericEnvironment] Include original parameter packs in opened pack element signatures.
2022-11-28 15:34:35 -05:00
Xi Ge
5987654b3a Merge branch 'main' into allowable-serialization 2022-11-28 09:36:04 -08:00
Xi Ge
67bbab7e02 serialization: encode allowable client names in binary module format 2022-11-25 18:43:40 -08:00
Holly Borla
8ec5405a30 [GenericEnvironment] Store a substitution map for the outer generic parameters
of an opened pack element generic environment.
2022-11-23 11:17:05 -05:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Doug Gregor
51fcde7b76 Merge pull request #62086 from DougGregor/macro-decl 2022-11-13 20:25:48 -08:00
Doug Gregor
5ab6b72604 [Macros] Turn Macro into a declaration node.
Although the declaration of macros doesn't appear in Swift source code
that uses macros, they still operate as declarations within the
language. Rework `Macro` as `MacroDecl`, a generic value declaration,
which appropriate models its place in the language.

The vast majority of this change is in extending all of the various
switches on declaration kinds to account for macros.
2022-11-13 12:21:29 -08:00
Slava Pestov
1e00c3107a Serialization: Support PackType and PackExpansionType 2022-11-12 02:13:54 -05:00
Allan Shortlidge
af032afb9d Serialization: Break the cycle between Serialization and SymbolGraphGen.
Push the top level logic for writing out swiftmodules and associated files into the frontend library which has access to all the necessary dependencies.
2022-10-29 21:37:09 -07:00
Alexis Laferrière
2854c1b3cb [Serialization] Write in the swiftmodule if it's built from a swiftinterface
This information will allow us to distinguish swiftmodule built from
source vs swiftinterface.
2022-10-27 18:51:28 -07:00
Slava Pestov
9dfb6ea067 Merge pull request #61675 from slavapestov/element-generic-environment
AST: Opened element generic environments
2022-10-22 00:58:26 -04:00
Slava Pestov
68514b10b5 AST: Introduce ElementArchetypeType 2022-10-21 21:55:35 -04:00
Richard Wei
56e7cce809 [Macros] Parse MacroExpansionExpr and MacroExpansionDecl
Introduce `MacroExpansionExpr` and `MacroExpansionDecl` and plumb it through. Parse them in roughly the same way we parse `ObjectLiteralExpr`.

The syntax is gated under `-enable-experimental-feature Macros`.
2022-10-21 01:50:35 -07:00
Becca Royal-Gordon
f2a0ab79c7 Add basic Sema support for @_objcImplementation
Does not validate members yet; nor does it emit different metadata.
2022-10-18 17:21:56 -07:00
Hamish Knight
6aa44a1754 [AST] Remove @_typeSequence attribute
This is no longer needed now that we have the
ellipsis spelling.
2022-10-14 15:40:13 +01:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Holly Borla
9bb837a241 [AST] Rename SequenceArchetype to PackArchetype. 2022-10-10 16:25:26 -07:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Dario Rexin
210c68d8aa [SILOptimizer] Add prespecialization for arbitray reference types (#58846)
* [SILOptimizer] Add prespecialization for arbitray reference types

* Fix benchmark Package.swift

* Move SimpleArray to utils

* Fix multiple indirect result case

* Remove leftover code from previous attempt

* Fix test after rebase

* Move code to compute type replacements to SpecializedFunction

* Fix ownership when OSSA is enabled

* Fixes after rebase

* Changes after rebasing

* Add feature flag for layout pre-specialization

* Fix pre_specialize-macos.swift

* Add compiler flag to benchmark build

* Fix benchmark SwiftPM flags
2022-09-22 16:29:01 -07:00
Slava Pestov
c1b8690401 AST: Introduce special Builtin.TheTupleType singleton 2022-09-10 00:26:42 -04:00
QuietMisdreavus
f674b473ec introduce a @_documentation(...) attribute to influence SymbolGraphGen (#60242)
* add @_documentation(...) attribute to influence SymbolGraphGen

rdar://79049241
2022-09-06 14:12:42 -06:00
Alex Lorenz
8de79390be [interop][SwiftToCxx] add @_expose(Cxx) attribute support
This attribute instructs the compiler that this declaration should be included in the generated C++ bindings
2022-08-24 10:14:07 -07:00
Slava Pestov
5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04:00
Slava Pestov
cfb4e60a48 Merge pull request #60523 from slavapestov/fix-opened-generic-environment-identity
Serialization: Preserve identity of opened generic environments
2022-08-16 14:33:44 -04:00
Slava Pestov
b36f37cc72 Serialization: Preserve identity of opened generic environments
We used to create a new environment for each opened archetype, which is
incorrect when deserializing a nested type of another opened archetype.
2022-08-15 13:59:12 -04:00
swift-ci
73280e6ed5 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-02 12:13:17 -07:00
Hamish Knight
9da53193da [AST] Remove ParameterTypeFlags from ParenType and TupleType
The last clients that relied on stashing parameter
type flags on these types are now gone.
2022-08-02 13:56:32 +01:00
swift-ci
2e1140c767 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-29 09:14:45 -07:00
Ben Barham
ee8bc34795 [Serialization] Output precedence higher/lowerThan relations when valid
When allowing errors, do not output higher/lowerThan relations for
invalid precedencegroup declarations.

Resolves rdar://97362356.
2022-07-28 12:23:12 -07:00
swift-ci
5706f48a31 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 19:14:34 -07:00
Pavel Yaskevich
225341e3d2 [Decl] Start storing and serializing "unavailability" bit per condition 2022-07-20 13:26:43 -07:00
Pavel Yaskevich
8185db433a [Serialization] Add a "unavailable" bit to conditional substitution record
A step towards supporting different opaque result type produced by a
`if #unavailable` block.
2022-07-20 13:26:41 -07:00
swift-ci
e9c324099a Merge remote-tracking branch 'origin/main' into rebranch 2022-07-18 16:13:31 -07:00
Alexis Laferrière
36b87d3c5c [Serialization] Use a more reliable macro to get the compiler tag
Use only the SWIFT_COMPILER_VERSION macro to check for swiftmodules
being written by the same compiler that reads it. In practice, it's the
macro used for release builds of the compiler.

rdar://96868333
2022-07-18 13:20:20 -07:00
Ben Barham
4dfaa820ac [rebranch] Remove now unused function 2022-07-08 10:17:16 -07:00
swift-ci
5c8f1fcb12 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-02 17:03:37 -07:00
Michael Gottesman
198b974622 Merge pull request #59859 from gottesmm/pr-276c4e4220a25490659a285e8b94a36bd28ffede
[no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
2022-07-01 23:17:43 -07:00
Michael Gottesman
8f3fe63fed [no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
Since I am beginning to prepare for adding real move only types to the language,
I am renaming everything that has to do with copyable types "move only wrapped"
values instead of move only. The hope is this reduces/prevents any confusion in
between the two.
2022-07-01 17:26:13 -07:00
swift-ci
31af44324e Merge remote-tracking branch 'origin/main' into rebranch 2022-06-30 00:14:54 -07:00
Pavel Yaskevich
b2b1efd268 [Distributed] Decl: Add a new distributed-thunk bit
The flag is used to distinguish between regular functions/accessors
and synthesized distributed thunks.
2022-06-29 14:49:10 -07:00
swift-ci
55000f53be Merge remote-tracking branch 'origin/main' into rebranch 2022-06-17 10:15:14 -07:00