Skip to content

Commit 50da0b5

Browse files
committed
Add progress reports for bridging header compilation.
1 parent 2e38b48 commit 50da0b5

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,16 +2060,19 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
20602060
// swift::ASTContext
20612061
Progress progress("Importing Swift standard library");
20622062
swift_ast_sp->m_ast_context_ap->SetPreModuleImportCallback(
2063-
[&progress](llvm::StringRef module_name, bool is_overlay) {
2064-
progress.Increment(1, (is_overlay ? module_name.str() + " (overlay)"
2065-
: module_name.str()));
2063+
[&progress](llvm::StringRef module_name,
2064+
swift::ASTContext::ModuleImportKind kind) {
2065+
progress.Increment(1, (kind == swift::ASTContext::Overlay
2066+
? module_name.str() + " (overlay)"
2067+
: module_name.str()));
20662068
});
20672069

20682070
// Clear the callback function on scope exit to prevent an out-of-scope
20692071
// access of the progress local variable
20702072
auto on_exit = llvm::make_scope_exit([&]() {
20712073
swift_ast_sp->m_ast_context_ap->SetPreModuleImportCallback(
2072-
[](llvm::StringRef module_name, bool is_overlay) {
2074+
[](llvm::StringRef module_name,
2075+
swift::ASTContext::ModuleImportKind kind) {
20732076
Progress("Importing Swift modules");
20742077
});
20752078
});
@@ -2569,19 +2572,22 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
25692572
const bool can_create = true;
25702573

25712574
// Report progress on module importing by using a callback function in
2572-
// swift::ASTContext
2575+
// swift::ASTContext.
25732576
Progress progress("Importing Swift standard library");
25742577
swift_ast_sp->m_ast_context_ap->SetPreModuleImportCallback(
2575-
[&progress](llvm::StringRef module_name, bool is_overlay) {
2576-
progress.Increment(1, (is_overlay ? module_name.str() + " (overlay)"
2577-
: module_name.str()));
2578+
[&progress](llvm::StringRef module_name,
2579+
swift::ASTContext::ModuleImportKind kind) {
2580+
progress.Increment(1, (kind == swift::ASTContext::Overlay
2581+
? module_name.str() + " (overlay)"
2582+
: module_name.str()));
25782583
});
25792584

25802585
// Clear the callback function on scope exit to prevent an out-of-scope
2581-
// access of the progress local variable
2586+
// access of the progress local variable.
25822587
auto on_exit = llvm::make_scope_exit([&]() {
25832588
swift_ast_sp->m_ast_context_ap->SetPreModuleImportCallback(
2584-
[](llvm::StringRef module_name, bool is_overlay) {
2589+
[](llvm::StringRef module_name,
2590+
swift::ASTContext::ModuleImportKind kind) {
25852591
Progress("Importing Swift modules");
25862592
});
25872593
});
@@ -3627,19 +3633,31 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const SourceModule &module,
36273633
auto import_diags = getScopedDiagnosticConsumer();
36283634

36293635
// Report progress on module importing by using a callback function in
3630-
// swift::ASTContext
3636+
// swift::ASTContext.
36313637
Progress progress("Importing Swift modules");
3632-
ast->SetPreModuleImportCallback([&progress](llvm::StringRef module_name,
3633-
bool is_overlay) {
3634-
progress.Increment(
3635-
1, (is_overlay ? module_name.str() + " (overlay)" : module_name.str()));
3636-
});
3638+
ast->SetPreModuleImportCallback(
3639+
[&progress](llvm::StringRef module_name,
3640+
swift::ASTContext::ModuleImportKind kind) {
3641+
switch (kind) {
3642+
case swift::ASTContext::Module:
3643+
progress.Increment(1, module_name.str());
3644+
break;
3645+
case swift::ASTContext::Overlay:
3646+
progress.Increment(1, module_name.str() + " (overlay)");
3647+
break;
3648+
case swift::ASTContext::BridgingHeader:
3649+
progress.Increment(1,
3650+
"Compiling bridging header: " + module_name.str());
3651+
break;
3652+
}
3653+
});
36373654

36383655
// Clear the callback function on scope exit to prevent an out-of-scope access
36393656
// of the progress local variable
36403657
auto on_exit = llvm::make_scope_exit([&]() {
36413658
ast->SetPreModuleImportCallback(
3642-
[](llvm::StringRef module_name, bool is_overlay) {
3659+
[](llvm::StringRef module_name,
3660+
swift::ASTContext::ModuleImportKind kind) {
36433661
Progress("Importing Swift modules");
36443662
});
36453663
});

lldb/test/API/functionalities/progress_reporting/swift_progress_reporting/TestSwiftProgressReporting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_swift_progress_report(self):
3636

3737
beacons = [
3838
"Loading Swift module",
39+
"Compiling bridging header",
3940
"Importing modules used in expression",
4041
"Setting up Swift reflection",
4142
"Importing Swift module dependencies for main.swift",

0 commit comments

Comments
 (0)