Skip to content

[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 7 commits into from
Jun 8, 2023

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Jun 7, 2023

@bnbarham bnbarham requested a review from DougGregor June 7, 2023 19:32
@bnbarham bnbarham requested a review from a team as a code owner June 7, 2023 19:32
rintaro and others added 5 commits June 7, 2023 14:38
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)
@bnbarham bnbarham force-pushed the cherry-various-macro branch from e8272a8 to a183239 Compare June 7, 2023 21:39
@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 7, 2023

swiftlang/swift-syntax#1740

@swift-ci please test

bnbarham and others added 2 commits June 7, 2023 20:07
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)
@bnbarham bnbarham force-pushed the cherry-various-macro branch from a183239 to a9fa607 Compare June 8, 2023 03:07
@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 8, 2023

@swift-ci please test

@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 8, 2023

@swift-ci please test Linux platform

@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 8, 2023

@swift-ci please clean test Windows platform

@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 8, 2023

@swift-ci please test Linux platform

@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 8, 2023

@swift-ci please test Windows platform

@bnbarham bnbarham merged commit 223596b into swiftlang:release/5.9 Jun 8, 2023
@bnbarham bnbarham deleted the cherry-various-macro branch June 8, 2023 18:49
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