Skip to content

[lldb/Swift] Fix import attributes handing in following expression evaluation #1978

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
Oct 16, 2020

Conversation

medismailben
Copy link

Previously, when importing a Swift module it the REPL or a Playground, LLDB
would only cache the module name and reload the module at every expression
evaluation. Doing so means that, when LLDB transfers imports information from
the original source file to the new one, it is doing it with low fidelity,
because LLDB would not keep track of the import attributes used in the previous
expression evaluations.

Thanks to swiftlang/swift#33935, we can now cache the whole
swift::AttributedImport<swift::ImportedModule>> instead of only storing the
module name. This struct contains both the ImportedModule with the ModuleDecl
but also the ImportOptions set containing all the possible import attributes
(Exported / Testable / PrivateImport ...) of that import statement.

Now, before compiling and evaluating a Swift expression, LLDB fetches all the
attributed imports cached previously and add them to the ImplicitImportInfo
object that is used to create the ModuleDecl of the evaluated expression.
It allows for the ImportOptions to be propagated in the compiled expression.

This should fix some irregularities between the debugger and the
compiler regarding import statements.

rdar://65319954

Signed-off-by: Med Ismail Bennani [email protected]

@medismailben
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link

This LGTM with mine an Jonas' comments addressed. Please don't forget to cherry-pick to swift/next!

@medismailben medismailben force-pushed the swift/main branch 2 times, most recently from 0a50c6b to a9bd280 Compare October 16, 2020 01:05
@medismailben
Copy link
Author

@swift-ci test

@medismailben medismailben force-pushed the swift/main branch 2 times, most recently from 02b6cc3 to 32faa56 Compare October 16, 2020 04:26
@medismailben
Copy link
Author

@swift-ci test and merge

Previously, when importing a Swift module it the REPL or a Playground, LLDB
would only cache the module name and reload the module at every expression
evaluation. Doing so means that, when LLDB transfers imports information from
the original source file to the new one, it is doing it with low fidelity,
because LLDB would not keep track of the import attributes used in the previous
expression evaluations.

Thanks to swiftlang/swift#33935, we can now cache the whole
`swift::AttributedImport<swift::ImportedModule>>` instead of only storing the
module name. This struct contains both the `ImportedModule` with the `ModuleDecl`
but also the `ImportOptions` set containing all the possible import attributes
(Exported / Testable / PrivateImport ...) of that import statement.

Now, before compiling and evaluating a Swift expression, LLDB fetches all the
attributed imports cached previously and add them to the `ImplicitImportInfo`
object that is used to create the `ModuleDecl` of the evaluated expression.
It allows for the `ImportOptions` to be propagated in the compiled expression.

This should fix some irregularities between the debugger and the
compiler regarding import statements.

rdar://65319954

Signed-off-by: Med Ismail Bennani <[email protected]>
@medismailben
Copy link
Author

@swift-ci test

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.

4 participants