Skip to content

Commit 45b9b66

Browse files
author
git apple-llvm automerger
committed
Merge commit '9a495dd2d7e9' from swift/release/6.0 into stable/20230725
2 parents 1e4acd5 + 9a495dd commit 45b9b66

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,9 +2162,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
21622162
auto on_exit = llvm::make_scope_exit([&]() {
21632163
swift_ast_sp->m_ast_context_ap->SetPreModuleImportCallback(
21642164
[](llvm::StringRef module_name,
2165-
swift::ASTContext::ModuleImportKind kind) {
2166-
Progress("Importing Swift modules");
2167-
});
2165+
swift::ASTContext::ModuleImportKind kind) {});
21682166
});
21692167

21702168
swift::ModuleDecl *stdlib =
@@ -2718,9 +2716,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
27182716
auto on_exit = llvm::make_scope_exit([&]() {
27192717
swift_ast_sp->m_ast_context_ap->SetPreModuleImportCallback(
27202718
[](llvm::StringRef module_name,
2721-
swift::ASTContext::ModuleImportKind kind) {
2722-
Progress("Importing Swift modules");
2723-
});
2719+
swift::ASTContext::ModuleImportKind kind) {});
27242720
});
27252721

27262722
swift::ModuleDecl *stdlib =
@@ -3850,20 +3846,22 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const SourceModule &module,
38503846

38513847
// Report progress on module importing by using a callback function in
38523848
// swift::ASTContext.
3853-
Progress progress("Importing Swift modules");
3849+
std::unique_ptr<Progress> progress;
38543850
ast->SetPreModuleImportCallback(
38553851
[&progress](llvm::StringRef module_name,
38563852
swift::ASTContext::ModuleImportKind kind) {
3853+
if (!progress)
3854+
progress = std::make_unique<Progress>("Importing Swift modules");
38573855
switch (kind) {
38583856
case swift::ASTContext::Module:
3859-
progress.Increment(1, module_name.str());
3857+
progress->Increment(1, module_name.str());
38603858
break;
38613859
case swift::ASTContext::Overlay:
3862-
progress.Increment(1, module_name.str() + " (overlay)");
3860+
progress->Increment(1, module_name.str() + " (overlay)");
38633861
break;
38643862
case swift::ASTContext::BridgingHeader:
3865-
progress.Increment(1,
3866-
"Compiling bridging header: " + module_name.str());
3863+
progress->Increment(1, "Compiling bridging header: " +
3864+
module_name.str());
38673865
break;
38683866
}
38693867
});
@@ -3873,9 +3871,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const SourceModule &module,
38733871
auto on_exit = llvm::make_scope_exit([&]() {
38743872
ast->SetPreModuleImportCallback(
38753873
[](llvm::StringRef module_name,
3876-
swift::ASTContext::ModuleImportKind kind) {
3877-
Progress("Importing Swift modules");
3878-
});
3874+
swift::ASTContext::ModuleImportKind kind) {});
38793875
});
38803876

38813877
// Perform the import.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,22 @@ def test_swift_progress_report(self):
4545
"Importing Swift standard library",
4646
]
4747

48+
importing_swift_reports = []
4849
while len(beacons):
4950
event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
5051
ret_args = lldb.SBDebugger.GetProgressFromEvent(event)
5152
if self.TraceOn():
5253
print(ret_args[0])
5354

55+
# When importing Swift modules, make sure that we don't get two reports
56+
# in a row with the title "Importing Swift modules", i.e. there should be
57+
# a report with that title followed by a report with that title and details
58+
# attached.
59+
if ret_args[0] == "Importing Swift modules":
60+
next_event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
61+
next_ret_args = lldb.SBDebugger.GetProgressFromEvent(next_event)
62+
self.assertRegexpMatches(next_ret_args[0], r"Importing Swift modules:+")
63+
5464
for beacon in beacons:
5565
if beacon in ret_args[0]:
5666
beacons.remove(beacon)

0 commit comments

Comments
 (0)