-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ASTContext] Add setter for PreModuleImportCallback #69730
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
[ASTContext] Add setter for PreModuleImportCallback #69730
Conversation
`PreModuleImportCallback` is a variable for a callback function used specifically by LLDB to report progress updates on importing Swift modules in LLDB. This commit adds a setter for `PreModuleImportCallback` for greater flexibility in LLDB and removes the reference to this variable in the constructor. Related to swiftlang/llvm-project#7769 rdar://105286354
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend = nullptr, | ||
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback = {}); | ||
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend = nullptr | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting formatting. Is that really clang-format
's output ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it is, other than removing the callback in the constructor I didn't change anything else here.
lib/AST/ASTContext.cpp
Outdated
@@ -715,6 +714,10 @@ ASTContext::~ASTContext() { | |||
getImpl().~Implementation(); | |||
} | |||
|
|||
void ASTContext::SetPreModuleImportCallback(std::function<bool(llvm::StringRef ModuleName, bool IsOverlay)> callback) { | |||
ASTContext::PreModuleImportCallback = callback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to qualify PreModuleImportCallback
here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't, but I think I originally thought that PreModuleImportCallback
was static even though it's not so I can remove the qualification.
FWIW, although this callback is used mainly as an LLDB module loading progress callback, it could also be used for/by other things. I'd retitle this PR to be more generic. |
@swift-ci test |
Good point about |
include/swift/AST/ASTContext.h
Outdated
@@ -294,6 +294,8 @@ class ASTContext final { | |||
/// OutputBackend for writing outputs. | |||
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutputBackend; | |||
|
|||
void SetPreModuleImportCallback(std::function<bool(llvm::StringRef ModuleName, bool IsOverlay)> callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doxygen comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll add one here
Sets the `PreModuleImportCallback`'s setter return type to void to account for the lambda functions in LLDB's progress reporting not actually using its return value. Also adds a Doxygen comment for `SetPreModuleImportCallback`
@swift-ci test |
@swift-ci smoke test |
swiftlang/llvm-project#7769 |
swiftlang/llvm-project#7769 |
lib/AST/ASTContext.cpp
Outdated
@@ -715,6 +714,10 @@ ASTContext::~ASTContext() { | |||
getImpl().~Implementation(); | |||
} | |||
|
|||
void ASTContext::SetPreModuleImportCallback(std::function<void(llvm::StringRef ModuleName, bool IsOverlay)> callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this line clang-format
ted? Looks pretty long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should've been, but I can also shorten it myself if clang-format
is ignoring it for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If clang-format
says it's ok then it's fine
swiftlang/llvm-project#7769 |
1 similar comment
swiftlang/llvm-project#7769 |
Run `clang-format`
swiftlang/llvm-project#7769 |
2 similar comments
swiftlang/llvm-project#7769 |
swiftlang/llvm-project#7769 |
LLDB's progress reporting infrastructure has had the ability to add details to an overall progress report (added in https://reviews.llvm.org/D143690) but this had yet to be implemented in existing progress reports. This commit adds this functionality to progress reports made for Swift operations (such as caching user imports) so that instead of sending several individual progress reports for each step in these operations, one progress report is created and then incrementally updated. Importing Swift modules takes place in the Swift compiler which uses a callback function so that LLDB can perform its progress report. This originally called into a function in `lldb_private::SwiftASTContext` but will instead use a lambda function to increment a locally created progress report. Related to: swiftlang/swift#69730 rdar://105286354
LLDB's progress reporting infrastructure has had the ability to add details to an overall progress report (added in https://reviews.llvm.org/D143690) but this had yet to be implemented in existing progress reports. This commit adds this functionality to progress reports made for Swift operations (such as caching user imports) so that instead of sending several individual progress reports for each step in these operations, one progress report is created and then incrementally updated. Importing Swift modules takes place in the Swift compiler which uses a callback function so that LLDB can perform its progress report. This originally called into a function in `lldb_private::SwiftASTContext` but will instead use a lambda function to increment a locally created progress report. Related to: swiftlang/swift#69730 rdar://105286354 (cherry picked from commit 4106480)
LLDB's progress reporting infrastructure has had the ability to add details to an overall progress report (added in https://reviews.llvm.org/D143690) but this had yet to be implemented in existing progress reports. This commit adds this functionality to progress reports made for Swift operations (such as caching user imports) so that instead of sending several individual progress reports for each step in these operations, one progress report is created and then incrementally updated. Importing Swift modules takes place in the Swift compiler which uses a callback function so that LLDB can perform its progress report. This originally called into a function in `lldb_private::SwiftASTContext` but will instead use a lambda function to increment a locally created progress report. Related to: swiftlang/swift#69730 rdar://105286354 (cherry picked from commit 4106480)
PreModuleImportCallback
is a variable for a callback function called before module importing in the Swift compiler. It is currently being used by LLDB to report progress updates on importing Swift modules in LLDB. This commit adds a setter forPreModuleImportCallback
for greater flexibility in LLDB and removes the reference to this variable in the constructor.Related to swiftlang/llvm-project#7769
rdar://105286354