-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.9] Macro refactorings and fixes #66426
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DougGregor
approved these changes
Jun 7, 2023
Introduce 'createMacroSourceFile()' that creates macro expanded 'SourceFile' object. Use it from various macro expansion functions. (cherry picked from commit 78b2229)
'MacroExpansionDecl' and 'MacroExpansionExpr' have many common methods. Introduce a common base class 'FreestandingMacroExpansion' that holds 'MacroExpansionInfo'. Factor out common expansion logic to 'evaluateFreestandingMacro' function that resembles 'evaluateAttachedMacro'. (cherry picked from commit 86d405b)
…acros Fixes a crash where local variables introduced by a freestanding declaration macro would not get SIL emitted for them, rdar://109721114. (cherry picked from commit 0caa453)
Some places want to do in-order walks of MacroExpansionDecls, but still visit auxiliary declarations. Rather than force them to specifically filter out declarations from the MacroExpansionDecl, add a parameter to visitAuxiliaryDecls to skip them. (cherry picked from commit 954a0db)
(cherry picked from commit 7082074)
e8272a8
to
a183239
Compare
@swift-ci please test |
After visiting declarations, also walk into their auxiliary decls if expansions are being walked. Resolves rdar://109548265. (cherry picked from commit b3af130)
Expand macros in the specified source file syntactically (without any module imports, nor typechecking). Request would look like: ``` { key.compilerargs: [...] key.sourcefile: <file name> key.sourcetext: <source text> (optional) key.expansions: [<expansion specifier>...] } ``` `key.compilerargs` are used for getting plugins search paths. If `key.sourcetext` is not specified, it's loaded from the file system. Each `<expansion sepecifier>` is ``` { key.offset: <offset> key.modulename: <plugin module name> key.typename: <macro typename> key.macro_roles: [<macro role UID>...] } ``` Clients have to provide the module and type names because that's semantic. Response is a `CategorizedEdits` just like (semantic) "ExpandMacro" refactoring. But without `key.buffer_name`. Nested expnasions are not supported at this point. (cherry picked from commit c3d1304)
a183239
to
a9fa607
Compare
@swift-ci please test |
@swift-ci please test Linux platform |
@swift-ci please clean test Windows platform |
@swift-ci please test Linux platform |
@swift-ci please test Windows platform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SourceFile
creation of macro expansions and unifiesMacroExpansionDecl
andMacroExpansionExpr