-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Macros] [SE-0382] Implement macros defined as expansions of other macros #64641
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
[Macros] [SE-0382] Implement macros defined as expansions of other macros #64641
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test |
289f05a
to
ea0398d
Compare
@swift-ci please smoke test |
@swift-ci please smoke test |
@@ -2,6 +2,9 @@ | |||
// | |||
// REQUIRES: nonexecutable_test | |||
// REQUIRES: swift_swift_parser | |||
// FIXME: Swift parser is not enabled on Linux CI yet. | |||
// REQUIRES: OS=macosx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you ran into whatever I ran into in #64089 that caused me not to merge it, though I don't remember what it was 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YEAH :(
In preparation for supporting macros that are defined in terms of other macros, adopt macro definition checking provided by the `MacroDeclSyntax.checkDefinition` operation (implemented in swift-syntax). Use this in lieu of the checking on the C++ side. This required me to finally fix an issue with the source ranges for Fix-Its, where we were replacing the leading/trailing trivia of nodes along with the node itself, even though that's incorrect: we should only replce the node itself, and there are other Fix-It kinds for replacing leading or trailing trivia.
We were enabling the `$Macros` feature unconditionally, even when the compiler itself doesn't support macros (because it's missing swift-syntax). Change this to only enable the feature when the compiler supports it.
Handle a trivial macro defined in terms of another macro.
This enables macros to be defined in terms of other macros.
These expressions are a little tricky, because we don't always type-check them in the way that clients would expect. We might want to change the representation here, but until then... don't walk the untypechecked ones.
This should complete the implementation of expanded macro definitions, rdar://104044325.
58fe207
to
68b367b
Compare
@swift-ci please smoke test |
Implement support for defining a macro in terms of the expansion of another macro, e.g.,
There are a few steps along the way:
MacroDeclSyntax.checkDefinition
operation (implemented in swift-syntax) in lieu of the checking we currently do on the C++ side$Macros
for compilers that can actually expand macros, and make sure we only run tests that require macro checking for compiler that support expansion.This aspect of macros is tracked by rdar://104044325