Commit Graph

2076 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
af639e5bf4 [AST] RuntimeMetadata: Move getRuntimeDiscoverableAttrs to Decl
Reflection metadata attributes could be attached to a `ValueDecl`
and `ExtensionDecl`.
2023-01-30 14:03:40 -08:00
Alex Lorenz
1c2ba454f6 [interop] namespace printing should only print redecls from one module interface
This ensures that when we're printing multiple module interfaces, we separate out
the namespaces and their members correctly between the produced module interfaces.
2023-01-29 17:31:20 -08:00
Alex Lorenz
88c8893e80 [interop] AST printer should only visit one original namespace decl to avoid printing redecls over and over again
Also, lookup namespace members directly without doing a lookup. This helps us print the libc++ module interface in < 1s on M1
2023-01-29 12:01:07 -08:00
John McCall
d25a8aec8b Add explicit lowering for value packs and pack expansions.
- SILPackType carries whether the elements are stored directly
  in the pack, which we're not currently using in the lowering,
  but it's probably something we'll want in the final ABI.
  Having this also makes it clear that we're doing the right
  thing with substitution and element lowering.  I also toyed
  with making this a scalar type, which made it necessary in
  various places, although eventually I pulled back to the
  design where we always use packs as addresses.

- Pack boundaries are a core ABI concept, so the lowering has
  to wrap parameter pack expansions up as packs.  There are huge
  unimplemented holes here where the abstraction pattern will
  need to tell us how many elements to gather into the pack,
  but a naive approach is good enough to get things off the
  ground.

- Pack conventions are related to the existing parameter and
  result conventions, but they're different on enough grounds
  that they deserve to be separated.
2023-01-29 03:29:06 -05:00
Artem Chikin
959216c0f6 Merge pull request #63175 from artemcm/DeSugarArraysAndDictionariesWhenPrinting
[Compile Time Constant Extraction] Print desugared array, dictionary, optional types
2023-01-24 09:32:08 -08:00
Kavon Farvardin
1978553c75 fill in the MoveOnly* feature guards 2023-01-23 22:59:58 -08:00
Kavon Farvardin
1356694043 experimentally allow move-only classes
A lot of existing regression tests rely on there
being some form of move-only classes, despite
them being something that will not be available
to users (and not complete).

This change introduces a `MoveOnlyClasses`
experimental feature so that those tests don't
need to be fully rewritten just yet. You need to
include `-enable-experimental-feature MoveOnlyClasses` along with
`-enable-experimental-move-only` to get move-only classes.
2023-01-23 22:33:27 -08:00
Artem Chikin
544dae4713 [Compile Time Constant Extraction] Print desugared arrays, dictionaries, optionals
Resolves rdar://103187206
2023-01-23 17:12:31 -08:00
Artem Chikin
f85deb0008 [AST Printer] Add ability to print desugared arrays, dictionaries, optionals 2023-01-23 17:09:25 -08:00
Ellie Shin
91f785441f Merge pull request #62652 from apple/es-pkg-acl
[NFC] Add 'package' access modifier to AccessLevel
2023-01-20 13:58:15 -08:00
John McCall
0e3a9adc32 Add Builtin.PackIndex 2023-01-19 23:57:13 -05:00
Ellie Shin
37af51dc4c Merge branch 'main' into es-pkg-acl 2023-01-19 16:18:17 -08:00
Ellie Shin
1c66d02f92 Add package access level to enum AccessLevel
Resolves rdar://104198440
2023-01-19 15:54:18 -08:00
Holly Borla
3f462f0f43 [Decl] Add MissingDecl to use for parser recovery. 2023-01-15 09:55:15 -08:00
Doug Gregor
9e76023546 Add BuiltinCreateTaskGroupWithFlags feature and use it to guard the builtin 2023-01-11 13:47:28 -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
Pavel Yaskevich
020db2350b [AST] TypeWrappers: Always allow attributes that come from swiftinterfaces
Since type wrapper attributes could be applied to protocols and
the protocol types could be used as existential values, it's not
always possible to wrap all uses of feature into `#if $TypeWrappers`
block so let's allow use of attributes if they come from a Swift
interface file.
2023-01-04 16:04:28 -08:00
Michael Gottesman
b95fe48a90 Merge pull request #62742 from gottesmm/pr-947919228bebf49e02eae5aedb1efee8038c2b4b
[borrow-expr] Add simple support for borrow-expr and wire it up to SILGenApply
2023-01-03 08:04:33 -08:00
Doug Gregor
0c5436211c Merge pull request #62768 from DougGregor/macro-omnibus 2023-01-03 07:13:16 -08:00
swift-ci
72146501a1 Merge pull request #62745 from tshortli/has-symbol-clang-decls
Sema/IRGen: Add clang decl support to `#_hasSymbol`
2023-01-03 01:25:34 -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
Allan Shortlidge
e8f1d9f59f AST: Fix a warning in ASTPrinter.cpp. 2022-12-22 10:55:29 -05:00
Michael Gottesman
947919228b [borrow-expr] Add simple support for borrow-expr but don't wire it up to anything. 2022-12-21 14:36:43 -08:00
Pavel Yaskevich
529269946d [AST] Drop ResultBuilderASTTransform feature flag 2022-12-21 12:18:02 -08:00
Pavel Yaskevich
43904e5a89 [ASTPrinter] Mark declarations with runtime attributes as using the feature 2022-12-20 09:45:01 -08:00
Holly Borla
d3bc4f52bc Merge pull request #62582 from hborla/pack-element-expr 2022-12-16 11:42:53 -05:00
Doug Gregor
33589de62f Experimentally emit diagnostics from the new Swift parser
Introduce the experimental feature `ParserDiagnostics`, which emits
diagnostics from the new Swift parser *first* for a source file. If
that produces any errors, we suppress any diagnostics emitted from the
C++ parser.
2022-12-15 21:24:44 -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
Holly Borla
f1fd9acb23 [AST] Add 'PackElementExpr' for explicit pack elements spelled with the 'each'
keyword.
2022-12-14 20:45:51 -08:00
Pavel Yaskevich
5c11a4b894 [ASTPrinter] TypeWrappers: print inferred attributes 2022-12-14 17:50:28 -08:00
Pavel Yaskevich
fa62cf3827 [ASTPrinter] Expand type wrapper feature coverage
`usesFeatureTypeWrappers` should return `true` for all of
the declarations that use the feature directly or indirectly
e.g. type wrapper types, type wrapped types, and types with
conformance to a type wrapped protocol (with or without wrapper
attribute inference).
2022-12-14 12:17:24 -08:00
Zoe Carver
9850906570 Merge pull request #62330 from zoecarver/conforms-to-attr
[cxx-interop] Add ability to specify protocol conformance on C++ side.
2022-12-13 16:28:31 -08:00
Alexis Laferrière
276281ded8 Merge pull request #62476 from xymus/module-interface-export-as
[ModuleInterface] Ignore export_as in private swiftinterface
2022-12-13 09:12:44 -08:00
Ben Rimmington
620ba334fb [SE-0368] StaticBigInt: support older compilers (#62541) 2022-12-13 11:15:48 +00: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
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
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
zoecarver
5eb7c7a6cf [cxx-interop] Add ability to specify protocol conformance on C++ side. 2022-11-30 17:26:15 -07:00
Allan Shortlidge
85ddda128b AST: Introduce a getFirstElement() utility on EnumCaseDecl.
This utility helps codify the practice of using the attributes of the first element of a case decl as the attributes for the entire case.
2022-11-29 22:11:31 -08:00
Allan Shortlidge
2b0807d021 ModuleInterface: Avoid printing @_spi enum case decls in public swiftinterfaces.
rdar://72873771
2022-11-29 22:11:02 -08:00
Doug Gregor
1a124e71d6 [Macros] Implement AST printing and module interface generation for macros 2022-11-28 18:33:10 -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
Robert Widmann
d6cffbbe00 Merge pull request #62145 from CodaFi/synfonia
Delete libSyntax
2022-11-17 09:57:37 -08:00
Holly Borla
72e296e32b Merge pull request #62140 from hborla/variadic-generics-locators
[ConstraintSystem] Add locator path elements for pack expansion patterns and pack shapes.
2022-11-16 19:22:27 -08:00
Robert Widmann
91c262bcb7 Move TokenKinds.def.gyb to AST 2022-11-16 13:38:25 -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
Pavel Yaskevich
59163524a5 [Sema] Add skeleton implementation of @runtimeMetadata attribute
Use of the attribute is gated on `RuntimeDiscoverableAttrs` flag.
2022-11-15 17:33:13 -08:00
Holly Borla
9e21404013 [ASTPrinter] Fix a crash when printing pack element archetypes. 2022-11-15 17:23:15 -08:00