Skip to content

[5.9][Macro] Attributes for freestanding macro expansion #1675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 18, 2023

Cherry-pick #1650, #1654, #1666, (and depending #1508) into release/5.8

  • Explanation: Enable attributes and modifiers on macro expansion syntax. Attributes and modifiers on the expansion syntax are syntactically copied to the expanded declarations. Also, @available attributes are respected in the arguments of the expansion syntax e.g. @available(macOS 99, *) #someMacro(someAPIfromMacOS_99()).
  • Scope: Freestanding macro expansion parsing and expansion. And availability check inside freestanding macro expansion and expanded declarations.
  • Risk: Mid. The changes are relatively straightforward, but this touches broad area of the compiler and swift-syntax
  • Testing: Added regression test cases
  • Issue: rdar://107386648
  • Reviewers: Alex Hoppen (@ahoppen), Ben Barham (@bnbarham)

rintaro and others added 6 commits May 17, 2023 15:24
* Add `attributes` and `modifiers` to `MacroExpansionDeclSyntax`
* Diagnose whitespaces between # and the macro name
* Attach attributes to MacroExpansionDeclSyntax

rdar://107386648
(cherry picked from commit fd89876)
This module is a unified macro expansion logic shared between 'swift'
ASTGen and SwiftCompilerPluginMessageHandling

(cherry picked from commit c57b410)
As per the SE-0397 amendment, copy attributes and modifiers on
MacroExpansionDecl to the expanded declarations.
@rintaro
Copy link
Member Author

rintaro commented May 18, 2023

swiftlang/swift#65990
@swift-ci Please test

@DougGregor DougGregor merged commit fc8f9dc into swiftlang:release/5.9 May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants