Commit Graph

18 Commits

Author SHA1 Message Date
Doug Gregor
3f518a3b79 [Macros] Don't apply member attribute macros to accessors
Accessors are conceptually nested within their property or subscript
declarations, so member-attribute macros should only apply to the
property or subscript declarations. This eliminates what appears to be
redundant macro expansion.

Fixes rdar://118956800.
2023-12-13 09:26:52 -08:00
Ben Barham
9691060418 [Diagnostics] Add declaration name to macro_attached_to_invalid_decl
This could also use `%kind` for the declaration kind, but that ends up
being "extension of struct" instead of just "extension", which seems
slightly worse.
2023-07-25 16:03:52 -07:00
Holly Borla
a60b302754 [Macros] Diagnose invalid attached macros at the attribute location instead
of the declaration.
2023-07-21 16:31:10 -07:00
Holly Borla
04ea8b0a67 [Macros] Diagnose macros attached to declarations they cannot apply to. 2023-07-13 17:07:24 -07:00
Holly Borla
14e92b2678 [Macros] Don't apply member attribute macros to expanded members. 2023-05-31 17:14:39 -07:00
Doug Gregor
3547855148 [Macros] Mangle attached macros for accessors
Attached macro mangles for accessors were using a fallback case that
triggers an assertion in +Asserts builds, and conflicting manglings is
non-Asserts builds. Provide a custom mangling for these cases that's
embedded in the identifier.

This is a narrow hack to eliminate an assertion. We are considering a
different approach for the long term that uses entity manglings with a
placeholder type, which will be more flexible long-term.
2023-05-01 15:17:17 -07:00
Rintaro Ishizaki
02a604e7e7 [Tests/Macros] Add %target-codesign before %target-run
rdar://107658689
2023-04-05 12:48:09 -07:00
Ben Barham
e5a28caa9a [Test] Fix swift_swift_parser feature and use in tests
The macro tests were all using "REQUIRES: OS=macosx" as a proxy for
"have the Swift Swift parser". There was an existing feature for this,
but it was just checking whether the path was passed through. Fix that
to use the same variable as in CMake.

Also remove all extraneous `-I` and `-L` to the host libs in the target
invocations.
2023-04-03 09:25:03 -07:00
Rintaro Ishizaki
1d2fd4223f [Test] Add %host_triple and %host_sdkroot substitutions
Macro tests need to build host libraries/tools. We can't use %target-*
substitutions for that.

rdar://107398734
2023-03-31 07:41:41 -07:00
Doug Gregor
f88d2c638f Clean up feature flags for macros.
Enable expression macros by default, and add separate feature flags for
attached and freestanding macros.
2023-03-02 14:34:59 -08:00
Alex Hoppen
ba5a727983 [Macros] Compile Macros tests with swift-version 5 instead of swift-version 4 2023-02-04 11:10:08 +01:00
Doug Gregor
69edc787cf [Macros] Walk semantic attributes when checking a primary file 2023-02-01 23:09:36 -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
6c1debd1c4 [NFC] Don't rely on string interpolation of key-paths in attribute macro tests. 2023-01-19 13:49:56 -08:00
Holly Borla
0d7109710f [Macros] Pass the parent declaration of the member-to-expand to member
attribute macro expansions.
2023-01-15 11:36:47 -08:00
Holly Borla
ac7f05b887 [Macros] Apply expanded attributes to the member's semantic attribute list.
This change enables the first end-to-end test for member attribute macros!
2023-01-15 10:11:00 -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
4f8e1daa26 [Macros] Implement the skeleton of attribute macro expansion.
Attribute macros are expanded during AttachedSemanticAttrsRequest. This
change invokves the expansion, but it does nothing with the result yet.
The next step is to parse back in the attribute list, type check it, and
return the resulting attributes back to the request to add to the semantic
attribute list.
2023-01-15 10:11:00 -08:00