Skip to content

[Macros] Code item macros #64765

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
merged 1 commit into from
Apr 4, 2023
Merged

[Macros] Code item macros #64765

merged 1 commit into from
Apr 4, 2023

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Mar 30, 2023

Add support for declaring and expanding code item macros.

rdar://106326121

@rxwei
Copy link
Contributor Author

rxwei commented Mar 30, 2023

@swift-ci please smoke test

@rxwei rxwei force-pushed the code-item-macro branch from e9a5e5d to a7eddce Compare March 30, 2023 15:57
@rxwei
Copy link
Contributor Author

rxwei commented Mar 30, 2023

@swift-ci please smoke test

@ahoppen ahoppen removed their request for review March 30, 2023 19:00
@xedin xedin removed their request for review March 30, 2023 20:34
@rxwei rxwei force-pushed the code-item-macro branch from a7eddce to cb20be1 Compare March 31, 2023 00:51
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

@DougGregor
Copy link
Member

@swift-ci please smoke test

@rxwei rxwei force-pushed the code-item-macro branch from cb20be1 to 93427a6 Compare April 4, 2023 00:03
@rxwei rxwei requested a review from tshortli as a code owner April 4, 2023 00:03
Comment on lines +1347 to +1354
if (auto *substituteDecl = E->getSubstituteDecl()) {
if (doIt(substituteDecl))
return nullptr;
// Visiting the substitute macro expansion decl will visit the same
// argument list. Skip visiting it again.
shouldWalkArguments = false;
}

Copy link
Contributor Author

@rxwei rxwei Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DougGregor Because a MacroExpansionExpr and its substitute decl are sharing the argument list again after 1ba7c14, this became necessary to prevent the argument list from being visited twice. Otherwise it triggers an assertion failure in VarDeclUsageChecker.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This localized suppression of visiting the argument list makes sense to me, thanks for pointing it out.

@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please smoke test

1 similar comment
@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please smoke test

@rxwei rxwei force-pushed the code-item-macro branch from 3e57ef7 to 037e012 Compare April 4, 2023 05:56
@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please test

@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please smoke test

Add support for declaring and expanding code item macros.  Add experimental feature flag `CodeItemMacros`.
@rxwei rxwei force-pushed the code-item-macro branch from 037e012 to 01e6fe2 Compare April 4, 2023 16:55
@rxwei
Copy link
Contributor Author

rxwei commented Apr 4, 2023

@swift-ci please smoke test

@rxwei rxwei merged commit 33b49d4 into swiftlang:main Apr 4, 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