Commit Graph

26 Commits

Author SHA1 Message Date
Doug Gregor
b53026d8d4 [Macros] Macro-metaprogram macro roles
Introduce X-macros for the various macro roles, and use them to
macro-metaprogram a lot of boilerplate involved with introducing new
macro roles.
2023-11-13 22:37:54 -08:00
Doug Gregor
6ac69d8c3c Remove findMacroForCustomAttr in favor of namelookup::lookupMacros
The former was effectively a copy of the latter.
2023-07-25 14:16:50 -07:00
Holly Borla
725374e0d8 [Macros] Implement attached extension macros. 2023-06-27 21:22:12 -07:00
Alex Hoppen
1e505791e4 [CodeComplete] Offer completions for the names: argument of a macro declaration
When completing after `names:`, completion should offer the different ways you can specify the names, i.e. `arbitrary`, `named`, etc.

```
@freestanding(declaration, names: #^COMPLETE^#)
```

rdar://108535077
2023-04-28 17:20:45 -07:00
Alex Hoppen
6098a3ca2b [CodeCompletion] Support completion for macro roles and the 'names:' argument label
rdar://108163121
2023-04-27 21:48:06 -07:00
Alex Hoppen
becbdc8203 [Macros] Disallow declaration of codeItem macros 2023-04-27 21:48:06 -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
Richard Wei
01e6fe2936 [Macros] Code item macros
Add support for declaring and expanding code item macros.  Add experimental feature flag `CodeItemMacros`.
2023-04-04 09:54:57 -07:00
Holly Borla
a3caacd309 [Macros] Initial implementation of conformance macros. 2023-02-23 20:43:11 -08:00
Holly Borla
f04f512184 [Macros] Add a new macro role for attached peer macros. 2023-02-10 14:38:22 -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
f6f57a8099 [Macros] Rename "synthesized member macros" to "member macros". 2023-01-26 21:52:36 -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
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
8b9be30783 [Macros] Add a new macro role for synthesized member macros. 2023-01-22 21:19:21 -08:00
Holly Borla
09287a1bd6 [Macros] Separate determining whether a custom attribute is a macro and
type checking macro attribute arguments into two different requests.
2023-01-22 16:49:30 -08:00
Holly Borla
8221409931 [Macros] Distinguish between attributes that do not reference macros and
invalid macro attributes in `findMacroForCustomAttr`.
2023-01-22 12:45:18 -08:00
Holly Borla
0ca5b8a1f9 [NFC] Move findMacroForCustomAttr to TypeCheckMacros.cpp. 2023-01-21 12:23:34 -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
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
0b8c335a97 [Macros] Allow custom attributes to resolve to attached macro declarations.
Introduce appropriate name lookup for custom attributes to find macros
at module scope, and prefer those to types of the same name. We don't
do anything with the macros we found other than ignore them, for the
moment.
2023-01-11 23:12:56 -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