Skip to content

Commit 21c390f

Browse files
committed
Revert "[AST] Add mechanism to notify module loading to other clients"
This reverts commit 38146fc.
1 parent 768a82f commit 21c390f

File tree

2 files changed

+40
-61
lines changed

2 files changed

+40
-61
lines changed

include/swift/AST/ASTContext.h

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,11 @@ class ASTContext final {
223223
ASTContext(const ASTContext&) = delete;
224224
void operator=(const ASTContext&) = delete;
225225

226-
ASTContext(
227-
LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
228-
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
229-
ClangImporterOptions &ClangImporterOpts,
230-
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
231-
SourceManager &SourceMgr, DiagnosticEngine &Diags,
232-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback = {});
226+
ASTContext(LangOptions &langOpts, TypeCheckerOptions &typecheckOpts,
227+
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
228+
ClangImporterOptions &ClangImporterOpts,
229+
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
230+
SourceManager &SourceMgr, DiagnosticEngine &Diags);
233231

234232
public:
235233
// Members that should only be used by ASTContext.cpp.
@@ -240,13 +238,11 @@ class ASTContext final {
240238

241239
void operator delete(void *Data) throw();
242240

243-
static ASTContext *
244-
get(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
245-
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
246-
ClangImporterOptions &ClangImporterOpts,
247-
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
248-
SourceManager &SourceMgr, DiagnosticEngine &Diags,
249-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback = {});
241+
static ASTContext *get(LangOptions &langOpts, TypeCheckerOptions &typecheckOpts,
242+
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
243+
ClangImporterOptions &ClangImporterOpts,
244+
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
245+
SourceManager &SourceMgr, DiagnosticEngine &Diags);
250246
~ASTContext();
251247

252248
/// Optional table of counters to report, nullptr when not collecting.
@@ -378,10 +374,6 @@ class ASTContext final {
378374
llvm::BumpPtrAllocator &
379375
getAllocator(AllocationArena arena = AllocationArena::Permanent) const;
380376

381-
/// An optional generic callback function invoked prior to importing a module.
382-
mutable std::function<bool(llvm::StringRef ModuleName, bool IsOverlay)>
383-
PreModuleImportCallback;
384-
385377
public:
386378
/// Allocate - Allocate memory from the ASTContext bump pointer.
387379
void *Allocate(unsigned long bytes, unsigned alignment,
@@ -1115,9 +1107,6 @@ class ASTContext final {
11151107
/// If a module by this name has already been loaded, the existing module will
11161108
/// be returned.
11171109
///
1118-
/// \param ModulePath The module's \c ImportPath which describes
1119-
/// the name of the module being loaded, possibly including submodules.
1120-
11211110
/// \returns The requested module, or NULL if the module cannot be found.
11221111
ModuleDecl *getModule(ImportPath::Module ModulePath);
11231112

lib/AST/ASTContext.cpp

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
#include "swift/AST/PropertyWrappers.h"
4343
#include "swift/AST/ProtocolConformance.h"
4444
#include "swift/AST/RawComment.h"
45-
#include "swift/AST/SILLayout.h"
4645
#include "swift/AST/SearchPathOptions.h"
46+
#include "swift/AST/SILLayout.h"
4747
#include "swift/AST/SemanticAttrs.h"
4848
#include "swift/AST/SourceFile.h"
4949
#include "swift/AST/SubstitutionMap.h"
@@ -65,7 +65,6 @@
6565
#include "llvm/IR/LLVMContext.h"
6666
#include "llvm/Support/Allocator.h"
6767
#include "llvm/Support/Compiler.h"
68-
#include "llvm/Support/FormatVariadic.h"
6968
#include <algorithm>
7069
#include <memory>
7170

@@ -579,13 +578,13 @@ void ASTContext::operator delete(void *Data) throw() {
579578
AlignedFree(Data);
580579
}
581580

582-
ASTContext *ASTContext::get(
583-
LangOptions &langOpts, TypeCheckerOptions &typeckOpts, SILOptions &silOpts,
584-
SearchPathOptions &SearchPathOpts, ClangImporterOptions &ClangImporterOpts,
585-
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
586-
SourceManager &SourceMgr, DiagnosticEngine &Diags,
587-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback) {
588-
// If more than two data structures are concatentated, then the aggregate
581+
ASTContext *ASTContext::get(LangOptions &langOpts,
582+
TypeCheckerOptions &typecheckOpts, SILOptions &silOpts,
583+
SearchPathOptions &SearchPathOpts,
584+
ClangImporterOptions &ClangImporterOpts,
585+
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
586+
SourceManager &SourceMgr, DiagnosticEngine &Diags) {
587+
// If more than two data structures are concatenated, then the aggregate
589588
// size math needs to become more complicated due to per-struct alignment
590589
// constraints.
591590
auto align = std::max(alignof(ASTContext), alignof(Implementation));
@@ -595,21 +594,19 @@ ASTContext *ASTContext::get(
595594
impl = reinterpret_cast<void *>(
596595
llvm::alignAddr(impl, llvm::Align(alignof(Implementation))));
597596
new (impl) Implementation();
598-
return new (mem) ASTContext(langOpts, typeckOpts, silOpts, SearchPathOpts,
599-
ClangImporterOpts, SymbolGraphOpts, SourceMgr,
600-
Diags, PreModuleImportCallback);
597+
return new (mem)
598+
ASTContext(langOpts, typecheckOpts, silOpts, SearchPathOpts,
599+
ClangImporterOpts, SymbolGraphOpts, SourceMgr, Diags);
601600
}
602601

603-
ASTContext::ASTContext(
604-
LangOptions &langOpts, TypeCheckerOptions &typeckOpts, SILOptions &silOpts,
605-
SearchPathOptions &SearchPathOpts, ClangImporterOptions &ClangImporterOpts,
606-
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
607-
SourceManager &SourceMgr, DiagnosticEngine &Diags,
608-
std::function<bool(llvm::StringRef, bool)> PreModuleImportCallback)
602+
ASTContext::ASTContext(LangOptions &langOpts, TypeCheckerOptions &typecheckOpts,
603+
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
604+
ClangImporterOptions &ClangImporterOpts,
605+
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
606+
SourceManager &SourceMgr, DiagnosticEngine &Diags)
609607
: LangOpts(langOpts), TypeCheckerOpts(typecheckOpts), SILOpts(silOpts),
610608
SearchPathOpts(SearchPathOpts), ClangImporterOpts(ClangImporterOpts),
611609
SymbolGraphOpts(SymbolGraphOpts), SourceMgr(SourceMgr), Diags(Diags),
612-
PreModuleImportCallback(PreModuleImportCallback),
613610
evaluator(Diags, langOpts), TheBuiltinModule(createBuiltinModule(*this)),
614611
StdlibModuleName(getIdentifier(STDLIB_NAME)),
615612
SwiftShimsModuleName(getIdentifier(SWIFT_SHIMS_NAME)),
@@ -625,18 +622,18 @@ ASTContext::ASTContext(
625622
The##SHORT_ID##Type(new (*this, AllocationArena::Permanent) \
626623
ID##Type(*this)),
627624
#include "swift/AST/TypeNodes.def"
628-
TheIEEE32Type(new (*this, AllocationArena::Permanent)
629-
BuiltinFloatType(BuiltinFloatType::IEEE32, *this)),
630-
TheIEEE64Type(new (*this, AllocationArena::Permanent)
631-
BuiltinFloatType(BuiltinFloatType::IEEE64, *this)),
632-
TheIEEE16Type(new (*this, AllocationArena::Permanent)
633-
BuiltinFloatType(BuiltinFloatType::IEEE16, *this)),
634-
TheIEEE80Type(new (*this, AllocationArena::Permanent)
635-
BuiltinFloatType(BuiltinFloatType::IEEE80, *this)),
636-
TheIEEE128Type(new (*this, AllocationArena::Permanent)
637-
BuiltinFloatType(BuiltinFloatType::IEEE128, *this)),
638-
ThePPC128Type(new (*this, AllocationArena::Permanent)
639-
BuiltinFloatType(BuiltinFloatType::PPC128, *this)) {
625+
TheIEEE32Type(new (*this, AllocationArena::Permanent)
626+
BuiltinFloatType(BuiltinFloatType::IEEE32,*this)),
627+
TheIEEE64Type(new (*this, AllocationArena::Permanent)
628+
BuiltinFloatType(BuiltinFloatType::IEEE64,*this)),
629+
TheIEEE16Type(new (*this, AllocationArena::Permanent)
630+
BuiltinFloatType(BuiltinFloatType::IEEE16,*this)),
631+
TheIEEE80Type(new (*this, AllocationArena::Permanent)
632+
BuiltinFloatType(BuiltinFloatType::IEEE80,*this)),
633+
TheIEEE128Type(new (*this, AllocationArena::Permanent)
634+
BuiltinFloatType(BuiltinFloatType::IEEE128, *this)),
635+
ThePPC128Type(new (*this, AllocationArena::Permanent)
636+
BuiltinFloatType(BuiltinFloatType::PPC128, *this)) {
640637

641638
// Initialize all of the known identifiers.
642639
#define IDENTIFIER_WITH_NAME(Name, IdStr) Id_##Name = getIdentifier(IdStr);
@@ -2214,8 +2211,6 @@ ASTContext::getModule(ImportPath::Module ModulePath) {
22142211
return M;
22152212

22162213
auto moduleID = ModulePath[0];
2217-
if (PreModuleImportCallback)
2218-
PreModuleImportCallback(moduleID.Item.str(), false /*=IsOverlay*/);
22192214
for (auto &importer : getImpl().ModuleLoaders) {
22202215
if (ModuleDecl *M = importer->loadModule(moduleID.Loc, ModulePath)) {
22212216
if (LangOpts.EnableModuleLoadingRemarks) {
@@ -2240,17 +2235,12 @@ ModuleDecl *ASTContext::getOverlayModule(const FileUnit *FU) {
22402235
return Existing;
22412236
}
22422237

2243-
if (PreModuleImportCallback) {
2244-
SmallString<16> path;
2245-
ModPath.getString(path);
2246-
if (!path.empty())
2247-
PreModuleImportCallback(path.str(), /*IsOverlay=*/true);
2248-
}
22492238
for (auto &importer : getImpl().ModuleLoaders) {
22502239
if (importer.get() == getClangModuleLoader())
22512240
continue;
2252-
if (ModuleDecl *M = importer->loadModule(SourceLoc(), ModPath))
2241+
if (ModuleDecl *M = importer->loadModule(SourceLoc(), ModPath)) {
22532242
return M;
2243+
}
22542244
}
22552245

22562246
return nullptr;

0 commit comments

Comments
 (0)