@@ -464,9 +464,11 @@ void SourceLookupCache::invalidate() {
464464// Module Implementation
465465// ===----------------------------------------------------------------------===//
466466
467- ModuleDecl::ModuleDecl (Identifier name, ASTContext &ctx)
468- : DeclContext(DeclContextKind::Module, nullptr ),
469- TypeDecl(DeclKind::Module, &ctx, name, SourceLoc(), { }) {
467+ ModuleDecl::ModuleDecl (Identifier name, ASTContext &ctx,
468+ ImplicitImportInfo importInfo)
469+ : DeclContext(DeclContextKind::Module, nullptr ),
470+ TypeDecl(DeclKind::Module, &ctx, name, SourceLoc(), {}),
471+ ImportInfo (importInfo) {
470472
471473 ctx.addDestructorCleanup (*this );
472474 setImplicit ();
@@ -475,6 +477,13 @@ ModuleDecl::ModuleDecl(Identifier name, ASTContext &ctx)
475477 setAccess (AccessLevel::Public);
476478}
477479
480+ ArrayRef<ImplicitImport> ModuleDecl::getImplicitImports () const {
481+ auto &evaluator = getASTContext ().evaluator ;
482+ auto *mutableThis = const_cast <ModuleDecl *>(this );
483+ return evaluateOrDefault (evaluator, ModuleImplicitImportsRequest{mutableThis},
484+ {});
485+ }
486+
478487bool ModuleDecl::isClangModule () const {
479488 return findUnderlyingClangModule () != nullptr ;
480489}
@@ -2245,36 +2254,6 @@ SourceFile::getCachedVisibleDecls() const {
22452254 return getCache ().AllVisibleValues ;
22462255}
22472256
2248- static void performAutoImport (
2249- SourceFile &SF,
2250- SourceFile::ImplicitModuleImportKind implicitModuleImportKind) {
2251- if (SF.Kind == SourceFileKind::SIL)
2252- assert (implicitModuleImportKind ==
2253- SourceFile::ImplicitModuleImportKind::None);
2254-
2255- ASTContext &Ctx = SF.getASTContext ();
2256- ModuleDecl *M = nullptr ;
2257-
2258- switch (implicitModuleImportKind) {
2259- case SourceFile::ImplicitModuleImportKind::None:
2260- return ;
2261- case SourceFile::ImplicitModuleImportKind::Builtin:
2262- M = Ctx.TheBuiltinModule ;
2263- break ;
2264- case SourceFile::ImplicitModuleImportKind::Stdlib:
2265- M = Ctx.getStdlibModule (true );
2266- break ;
2267- }
2268-
2269- assert (M && " unable to auto-import module" );
2270-
2271- // FIXME: These will be the same for most source files, but we copy them
2272- // over and over again.
2273- auto Imports = SourceFile::ImportedModuleDesc (
2274- ModuleDecl::ImportedModule ({}, M), SourceFile::ImportOptions ());
2275- SF.addImports (Imports);
2276- }
2277-
22782257llvm::StringMap<SourceFilePathInfo>
22792258SourceFile::getInfoForUsedFilePaths () const {
22802259 llvm::StringMap<SourceFilePathInfo> result;
@@ -2415,14 +2394,12 @@ ModuleDecl::computeMagicFileStringMap(bool shouldDiagnose) const {
24152394
24162395SourceFile::SourceFile (ModuleDecl &M, SourceFileKind K,
24172396 Optional<unsigned > bufferID,
2418- ImplicitModuleImportKind ModImpKind,
24192397 bool KeepParsedTokens, bool BuildSyntaxTree,
24202398 ParsingOptions parsingOpts)
24212399 : FileUnit(FileUnitKind::Source, M), BufferID(bufferID ? *bufferID : -1 ),
24222400 ParsingOpts(parsingOpts), Kind(K),
24232401 SyntaxInfo(new SourceFileSyntaxInfo(BuildSyntaxTree)) {
24242402 M.getASTContext ().addDestructorCleanup (*this );
2425- performAutoImport (*this , ModImpKind);
24262403
24272404 if (isScriptMode ()) {
24282405 bool problem = M.registerEntryPointFile (this , SourceLoc (), None);
0 commit comments