Skip to content

Commit 04316be

Browse files
Merge pull request #69730 from chelcassanova/lldb-swift-progress-reports
[ASTContext] Add setter for PreModuleImportCallback
2 parents 339d214 + b32a0ee commit 04316be

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

include/swift/AST/ASTContext.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ class ASTContext final {
239239
ClangImporterOptions &ClangImporterOpts,
240240
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
241241
SourceManager &SourceMgr, DiagnosticEngine &Diags,
242-
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend = nullptr,
243-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback = {});
242+
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend = nullptr
243+
);
244244

245245
public:
246246
// Members that should only be used by ASTContext.cpp.
@@ -257,8 +257,8 @@ class ASTContext final {
257257
ClangImporterOptions &ClangImporterOpts,
258258
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
259259
SourceManager &SourceMgr, DiagnosticEngine &Diags,
260-
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend = nullptr,
261-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback = {});
260+
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend = nullptr
261+
);
262262
~ASTContext();
263263

264264
/// Optional table of counters to report, nullptr when not collecting.
@@ -294,6 +294,11 @@ class ASTContext final {
294294
/// OutputBackend for writing outputs.
295295
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutputBackend;
296296

297+
/// Set the callback function that is invoked before Swift module importing is
298+
/// performed
299+
void SetPreModuleImportCallback(
300+
std::function<void(llvm::StringRef ModuleName, bool IsOverlay)> callback);
301+
297302
/// If the shared pointer is not a \c nullptr and the pointee is \c true,
298303
/// all operations working on this ASTContext should be aborted at the next
299304
/// possible opportunity.
@@ -404,7 +409,7 @@ class ASTContext final {
404409
getAllocator(AllocationArena arena = AllocationArena::Permanent) const;
405410

406411
/// An optional generic callback function invoked prior to importing a module.
407-
mutable std::function<bool(llvm::StringRef ModuleName, bool IsOverlay)>
412+
mutable std::function<void(llvm::StringRef ModuleName, bool IsOverlay)>
408413
PreModuleImportCallback;
409414

410415
public:

lib/AST/ASTContext.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,7 @@ ASTContext *ASTContext::get(
646646
ClangImporterOptions &ClangImporterOpts,
647647
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
648648
SourceManager &SourceMgr, DiagnosticEngine &Diags,
649-
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutputBackend,
650-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback) {
649+
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutputBackend) {
651650
// If more than two data structures are concatentated, then the aggregate
652651
// size math needs to become more complicated due to per-struct alignment
653652
// constraints.
@@ -661,7 +660,7 @@ ASTContext *ASTContext::get(
661660
return new (mem)
662661
ASTContext(langOpts, typecheckOpts, silOpts, SearchPathOpts,
663662
ClangImporterOpts, SymbolGraphOpts, SourceMgr, Diags,
664-
std::move(OutputBackend), PreModuleImportCallback);
663+
std::move(OutputBackend));
665664
}
666665

667666
ASTContext::ASTContext(
@@ -670,16 +669,15 @@ ASTContext::ASTContext(
670669
ClangImporterOptions &ClangImporterOpts,
671670
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
672671
SourceManager &SourceMgr, DiagnosticEngine &Diags,
673-
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend,
674-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback)
672+
llvm::IntrusiveRefCntPtr<llvm::vfs::OutputBackend> OutBackend
673+
)
675674
: LangOpts(langOpts), TypeCheckerOpts(typecheckOpts), SILOpts(silOpts),
676675
SearchPathOpts(SearchPathOpts), ClangImporterOpts(ClangImporterOpts),
677676
SymbolGraphOpts(SymbolGraphOpts), SourceMgr(SourceMgr), Diags(Diags),
678677
OutputBackend(std::move(OutBackend)), evaluator(Diags, langOpts),
679678
TheBuiltinModule(createBuiltinModule(*this)),
680679
StdlibModuleName(getIdentifier(STDLIB_NAME)),
681680
SwiftShimsModuleName(getIdentifier(SWIFT_SHIMS_NAME)),
682-
PreModuleImportCallback(PreModuleImportCallback),
683681
TheErrorType(new (*this, AllocationArena::Permanent) ErrorType(
684682
*this, Type(), RecursiveTypeProperties::HasError)),
685683
TheUnresolvedType(new(*this, AllocationArena::Permanent)
@@ -731,6 +729,11 @@ ASTContext::~ASTContext() {
731729
getImpl().~Implementation();
732730
}
733731

732+
void ASTContext::SetPreModuleImportCallback(
733+
std::function<void(llvm::StringRef ModuleName, bool IsOverlay)> callback) {
734+
PreModuleImportCallback = callback;
735+
}
736+
734737
llvm::BumpPtrAllocator &ASTContext::getAllocator(AllocationArena arena) const {
735738
switch (arena) {
736739
case AllocationArena::Permanent:

0 commit comments

Comments
 (0)