Commit Graph

3433 Commits

Author SHA1 Message Date
Holly Borla
5bfc7e6dac Merge pull request #63538 from hborla/peer-macros
[Macros] Initial implementation of peer macros.
2023-02-11 10:57:28 -08:00
Artem Chikin
02a1577e38 Merge pull request #63503 from artemcm/ConstExtractRuntimeMetadataAttr
[Compile Time Constant Extraction] Extract Runtime Metadata Attributes
2023-02-10 22:45:12 -07:00
Holly Borla
f04f512184 [Macros] Add a new macro role for attached peer macros. 2023-02-10 14:38:22 -08:00
Doug Gregor
04eca73d60 [Macros] Stop parsing the ": <type>" syntax. We always require parameters 2023-02-09 22:11:23 -08:00
Artem Chikin
d5f09b496a [Compile Time Constant Extraction] Extract runtime metadata attributes
Part of rdar://104192094
2023-02-08 14:31:44 -07:00
swift-ci
38c89bf212 Merge pull request #63491 from ktoso/wip-custom-executor-not-directly-on-actor
[CustomExecutors] unownedExecutor can be declared not directly on actor
2023-02-08 01:33:48 -08:00
Konrad `ktoso` Malawski
6b95ff7a25 [Concurrenncy] add internal way to assert we're on expected executor 2023-02-08 15:41:25 +09:00
Konrad `ktoso` Malawski
307ec5a378 [Concurrency] unownedExecutor can be declared not directly on actor 2023-02-08 13:38:02 +09:00
Pavel Yaskevich
1d2e1ed793 [AST] NFC: Move VarDecl::getPointerAuthQualifier implementation to Decl.cpp 2023-02-07 15:58:14 -08:00
Richard Wei
81943b2b11 [Macros] Clean up MacroExpansionDecl (#63486)
- Remove the `Rewritten` field and `setRewritten()`. Make `getRewritten()` invoke the request.
- Rename fields `Macro` and `MacroLoc` to `MacroName` and `MacroNameLoc` respectively as well as their getters to match those in `MacroExpansionExpr`.
2023-02-07 14:57:02 +08:00
Richard Wei
01e4c8df26 [Macros] Use name lookup for lazy declaration macro expansion (#63411)
- Use the name lookup table instead of adding members from a macro expansion to the parent decl context.
- Require declaration macros to specify introduced names and used the declared names to guide macro expansions lazily.
2023-02-07 11:24:42 +08:00
Ben Barham
5d684fb679 Merge pull request #63320 from bnbarham/index-objc-impl-crash
[AST] Avoid possible segfault in isDirectToStorageAccess
2023-02-06 15:49:04 -08:00
Doug Gregor
b1c20c926d Merge pull request #63418 from DougGregor/mangle-attached-macros 2023-02-03 16:23:17 -08:00
Ellie Shin
258b13b05d Merge pull request #63355 from apple/es-export-pr
Add access level and scope checks to package types
2023-02-03 15:20:29 -08:00
Doug Gregor
b63fa566ec [Macros] Add mangling for attached macro expansion.
Extend the name mangling scheme for macro expansions to cover attached
macros, and use that scheme for the names of macro expansions buffers.

Finishes rdar://104038303, stabilizing file/buffer names for macro
expansion buffers.
2023-02-03 13:30:16 -08:00
Ellie Shin
be20333a87 Add access level and scope checks to package types
Resolves rdar://104617227
2023-02-02 16:51:17 -08:00
Allan Shortlidge
d2524a6de8 AST: Implement parsing support for the accepted spelling of @backDeployed for SE-0376.
For source compatibility `@_backDeploy` continues to be accepted as a spelling.

rdar://102792909
2023-02-01 22:04:33 -08:00
Allan Shortlidge
aa5194cdc5 AST: Correct inferred availability attributes on synthesized declarations.
The `getInnermostDeclWithAvailability()` utility was not looking through extensions to the nominal type declaration when searching for enclosing availability.

Resolves rdar://104931478
2023-02-01 16:50:21 -08:00
Ben Barham
526016c5c1 [AST] Avoid possible segfault in isDirectToStorageAccess
`isAccessibleFrom` allows a `nullptr` for `useDC`. Thus `UseDC` can be a
`nullptr` in the path `checkAccess` -> `getAccessSemanticsFromContext`
-> `isDirectToStorageAccess`.

Resolves rdar://104620331.
2023-01-30 19:06:03 -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
Richard Wei
2eab34a865 [Macros] Unify macro resolution under ResolveMacroRequest (#63293)
This reverts an earlier revert (547d85e643) and fixes the Windows build.
2023-01-30 00:07:40 +08:00
Saleem Abdulrasool
547d85e643 Revert "[Macros] Unify macro resolution under ResolveMacroRequest" (#63289) 2023-01-28 11:49:00 -08:00
Richard Wei
1d6a54794f Merge pull request #63247 from rxwei/resolve-macro-request 2023-01-28 09:25:00 +08:00
Richard Wei
7d6994a200 [Macros] Unify macro resolution under ResolveMacroRequesto
Rename `ResolveAttachedMacroRequest` to `ResolveMacroRequest` and make use of the request in freestanding declaration macro type checking. Add support for type-checking generic arguments on `MacroExpansionDecl`.
2023-01-27 15:07:10 +08:00
Holly Borla
32a0705e90 [Macros] Use the singular 'memberAttribute' spelling for attached member
attribute macros.
2023-01-26 21:52:39 -08:00
Holly Borla
f6f57a8099 [Macros] Rename "synthesized member macros" to "member macros". 2023-01-26 21:52:36 -08:00
Holly Borla
3e6fdb8807 [NameLookup] The custom attribute lookup request only returns nominal types.
Macro attribute lookup is now implemented in ResolveMacroRequest, which happens
later because it needs overload resolution to resolve a custom attribute to a
macro decl.
2023-01-26 17:10:28 -08:00
Doug Gregor
4e50e29f3d Merge pull request #63233 from DougGregor/macros-mangle-buffer-names
[Macros] Mangle the names of macro expansion buffers
2023-01-26 06:57:15 -08:00
Doug Gregor
4ae434eaa1 [Macros] Add a mangling for macro expansions
These aren't ABI, but are useful to provide consistent names to refer
to macro expansions, e.g., in buffer names.
2023-01-25 22:45:14 -08:00
Doug Gregor
72ddbebc08 [Macros] Assign macro expansion discriminators more lazily.
This is a punt. They'll be unique, and they'll be per-context, but
they'll be lazy and therefore not stable.
2023-01-25 22:03:38 -08:00
Doug Gregor
6e3289d4d5 [Macros] Compute discriminators for freestanding macro expansions.
Introduce discriminators into freestanding macro expansion expressions
and declarations. Compute these discriminators alongside closure and
local-declaration discriminators, checking them in the AST verifier.
2023-01-25 22:03:38 -08:00
Doug Gregor
af7ce9e945 [Macros] Remove the @declaration attribute.
We have @freestanding working appropriately now.
2023-01-25 17:07:38 -08:00
Doug Gregor
c188ab4f91 Remove the "@expression" attribute now that it has a better spelling 2023-01-25 17:07:38 -08:00
Doug Gregor
d74f235eb9 Generalize @attached parsing and representation to also include @freestanding.
The attached and freestanding macro attributes use the same parsing
logic and representation, so generalize the "attached" attribute into
a more general "macro role" attribute.
2023-01-25 17:07:38 -08:00
Holly Borla
6a17bb64da [Macros] Factor out iteration over all attached macro attributes of a particular
role into `Decl::forEachAttachedMacro`.
2023-01-23 18:20:16 -08:00
Holly Borla
8b9be30783 [Macros] Add a new macro role for synthesized member macros. 2023-01-22 21:19:21 -08: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
Ellie Shin
792be3fe85 Modify AccessScope to allow checks for package access level
Resolves rdar://103534243
2023-01-19 15:50:32 -08:00
Ellie Shin
f26f810cc8 Merge pull request #62704 from apple/es-pkg2
[NFC] Modify AccessScope to allow checks for package access level
2023-01-19 09:09:27 -08:00
Ellie Shin
288dbe3842 Modify AccessScope to allow checks for package access level
Resolves rdar://103534243
2023-01-19 01:43:53 -08:00
Holly Borla
81492d1d96 [Macros] Requestify member attribute macro expansion directly.
Having a request for semantic declaration attributes while still allowing
the original linked list to be mutated directly can cause use-after-frees
on pointers to old decl attributes. For now, introduce a request that
expands member attribute macros with a side effect of adding the new
attributes to the list. We can revisit this once attribute mutation via
getAttrs() is audited across the frontend.
2023-01-17 19:48:22 -08:00
Holly Borla
5d7b280889 [Macros] Use @attached for member attribute macros.
Add MemberAttributes to MacroRole that corresponds to a `memberAttributes`
argument to the `@attached` attribute.
2023-01-15 10:11:00 -08:00
Holly Borla
3f462f0f43 [Decl] Add MissingDecl to use for parser recovery. 2023-01-15 09:55:15 -08:00
Holly Borla
ba7fb5d946 [Property Wrappers] Use getSemanticAttrs in AttachedPropertyWrappersRequest. 2023-01-15 09:55:15 -08:00
Holly Borla
2f170f6ecc [Sema] Introduce a requestified replacement for 'getAttrs'.
Introduce 'getSemanticAttrs', which is a requestified replacement for
'getAttrs'. Right now, AttachedSemanticAttrsRequest calls 'getAttrs',
meaning future additions or removals from the linked list will not be
reflected via 'getSemanticAttrs'. Callers of 'getAttrs' that rely on
mutation will need to turn the computation into a request and vend the
attributes through AttachedSemanticAttrsRequest.
2023-01-15 09:55:15 -08:00
Doug Gregor
43cadcad3a [Macros] Serialization and printing for @attached. 2023-01-14 21:48:43 -08:00
Doug Gregor
de16b47875 [Macros] Introduce the @attached attribute for declaring attached macros.
Describe attached macros with the `@attached` attribute, providing the
macro role and affected names as arguments to the macro. The form of
this macro will remain the same as it gains other kinds of attached
macro roles beyond "accessor".

Remove the "accessors" role from `@declaration`, which will be going
away.
2023-01-13 22:47:59 -08:00
Doug Gregor
69649a40a6 Generalize CustomAttrNominalRequest's name and signature to account for macros 2023-01-11 21:28:26 -08:00
Richard Wei
f17b7c48bf [Macros] Freestanding declaration macros
Add support for freestanding declaration macros.

- Parse `@declaration` attribute.
- Type check and expand `MacroExpansionDecl`.

Known issues:
- Generic macros are not yet handled.
- Expansion does not work when the parent decl context is `BraceStmt`. Need to parse freestanding declaration macro expansions in `BraceStmt` as `MacroExpansionDecl`, and add expanded decls to name lookup.
2023-01-10 19:09:11 -08:00