Skip to content

[AST] Add mechanism to notify module loading to other clients #59181

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

Conversation

medismailben
Copy link
Contributor

@medismailben medismailben commented May 31, 2022

This patch adds an optional callback function member to the AST Context.
The callback gets invoked when a new module (or overlay module) gets
loaded.

This can be used for instance by other clients, such as lldb, to perform
actions when a module gets loaded, like showing progress to the end-user.

rdar://94165195

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

@medismailben medismailben force-pushed the module-loading-callbacks branch from a97f092 to d3064d6 Compare May 31, 2022 21:49
@JDevlieghere
Copy link
Contributor

Did you consider making the callback a member of the ASTContext? Do the functions take different callbacks? I'm curious because that would require only adding a function + a member instead of changing 6 existing function signatures.

@adrian-prantl
Copy link
Contributor

All in all I'm not sure I like this version of the patch. If (most) dependencies are loaded through ASTContext, then we should only need to modify loadModule() since that's called by all the other functions eventually.
My idea from yesterday for letting the module loaders customize the message doesn't actually work, because we can't know ahead of time whether the import is going to succeed. So the best thing we can do is printing the name of the module and the fact that we're importing it.

@adrian-prantl
Copy link
Contributor

It would be useful if we had a way of communicating the compilation of Clang module dependencies of Clang modules, because that is very slow, but IIUC, not even ClangImporter know about this as it's handled by Clang? We could try building with -Rmodule-build and listening to the Diagnostics, but let's not make the perfect the enemy of the good. Even just printing the toplevel imports is better than nothing.

@medismailben medismailben force-pushed the module-loading-callbacks branch 2 times, most recently from 0b22a9a to 253a2e5 Compare June 2, 2022 21:34
@medismailben
Copy link
Contributor Author

Addressed @JDevlieghere & @adrian-prantl feedbacks

@medismailben
Copy link
Contributor Author

@swift-ci test

@medismailben medismailben requested a review from fredriss June 2, 2022 21:46
@medismailben medismailben changed the title [AST] Add callback to the module loading methods [AST] Add mechanism to notify module loading to other clients Jun 2, 2022
@medismailben medismailben force-pushed the module-loading-callbacks branch from 253a2e5 to 0d89418 Compare June 3, 2022 01:09
@medismailben
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

Reasonable change with a minor comment.

This patch adds an optional callback function member to the AST Context.
The callback gets invoked when a new module (or overlay module) gets
loaded.

This can be used for instance by other clients, such as lldb, to perform
actions when a module gets loaded, like showing progress to the end-user.

rdar://94165195

Signed-off-by: Med Ismail Bennani <[email protected]>
@medismailben medismailben force-pushed the module-loading-callbacks branch from 0d89418 to fc49b5c Compare June 7, 2022 23:05
@medismailben
Copy link
Contributor Author

@swift-ci test

@medismailben medismailben merged commit ffd9ed1 into swiftlang:release/5.7 Jun 8, 2022
@medismailben
Copy link
Contributor Author

Cherry-picked to main in #59466

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