Skip to content

[Macros] Fix lookup of macro-produced variables #65939

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 2 commits into from
May 18, 2023

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented May 16, 2023

Calling getInnermostDeclContext()->getParentSourceFile() on a macro-produced decl does not seem to be a reliable way to obtain the macro expansion source file, because PatternBindingDecl is not a DeclContext and getInnermostDeclContext() falls back outside the macro expansion file. This patch switches to using getSourceFileContainingLocation instead.

Resolves rdar://109376568.

@rxwei rxwei requested a review from DougGregor May 16, 2023 06:21
@rxwei
Copy link
Contributor Author

rxwei commented May 16, 2023

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented May 16, 2023

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented May 17, 2023

@swift-ci please smoke test macos

Calling `getInnermostDeclContext()->getParentSourceFile()` on a macro-produced decl does not seem to be a reliable way to obtain the macro expansion source file, because `PatternBindingDecl` is not a `DeclContext` and `getInnermostDeclContext()` falls back outside the macro expansion file. This patch switches to using `getSourceFileContainingLocation` when possible.

Resolves rdar://109376568.
@rxwei
Copy link
Contributor Author

rxwei commented May 17, 2023

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented May 17, 2023

@swift-ci please smoke test

@rxwei rxwei merged commit 9c91d1b into swiftlang:main May 18, 2023
@rxwei rxwei deleted the rdar109376568 branch May 18, 2023 22:32
rxwei added a commit to rxwei/swift that referenced this pull request May 18, 2023
Calling `getInnermostDeclContext()->getParentSourceFile()` on a macro-produced decl does not seem to be a reliable way to obtain the macro expansion source file, because `PatternBindingDecl` is not a `DeclContext` and `getInnermostDeclContext()` falls back outside the macro expansion file. This patch switches to using `getSourceFileContainingLocation` when possible.

Resolves rdar://109376568.
rxwei added a commit to rxwei/swift that referenced this pull request May 18, 2023
Calling `getInnermostDeclContext()->getParentSourceFile()` on a macro-produced decl does not seem to be a reliable way to obtain the macro expansion source file, because `PatternBindingDecl` is not a `DeclContext` and `getInnermostDeclContext()` falls back outside the macro expansion file. This patch switches to using `getSourceFileContainingLocation` when possible.

Resolves rdar://109376568.
meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request May 22, 2023
Calling `getInnermostDeclContext()->getParentSourceFile()` on a macro-produced decl does not seem to be a reliable way to obtain the macro expansion source file, because `PatternBindingDecl` is not a `DeclContext` and `getInnermostDeclContext()` falls back outside the macro expansion file. This patch switches to using `getSourceFileContainingLocation` when possible.

Resolves rdar://109376568.
NuriAmari pushed a commit to NuriAmari/swift that referenced this pull request May 28, 2023
Calling `getInnermostDeclContext()->getParentSourceFile()` on a macro-produced decl does not seem to be a reliable way to obtain the macro expansion source file, because `PatternBindingDecl` is not a `DeclContext` and `getInnermostDeclContext()` falls back outside the macro expansion file. This patch switches to using `getSourceFileContainingLocation` when possible.

Resolves rdar://109376568.
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.

2 participants