@@ -59,6 +59,7 @@ namespace swift {
5959 class FuncDecl ;
6060 class InfixOperatorDecl ;
6161 class LinkLibrary ;
62+ struct ImplicitImport ;
6263 class ModuleLoader ;
6364 class NominalTypeDecl ;
6465 class EnumElementDecl ;
@@ -158,6 +159,42 @@ enum class ResilienceStrategy : unsigned {
158159 Resilient
159160};
160161
162+ // / The kind of stdlib that should be imported.
163+ enum class ImplicitStdlibKind {
164+ // / No standard library should be implicitly imported.
165+ None,
166+
167+ // / The Builtin module should be implicitly imported.
168+ Builtin,
169+
170+ // / The regular Swift standard library should be implicitly imported.
171+ Stdlib
172+ };
173+
174+ struct ImplicitImportInfo {
175+ // / The implicit stdlib to import.
176+ ImplicitStdlibKind StdlibKind;
177+
178+ // / Whether we should attempt to import an underlying Clang half of this
179+ // / module.
180+ bool ShouldImportUnderlyingModule;
181+
182+ // / The bridging header path for this module, empty if there is none.
183+ StringRef BridgingHeaderPath;
184+
185+ // / The names of additional modules to be implicitly imported.
186+ SmallVector<Identifier, 4 > ModuleNames;
187+
188+ // / An additional list of already-loaded modules which should be implicitly
189+ // / imported.
190+ SmallVector<std::pair<ModuleDecl *, /* exported*/ bool >, 4 >
191+ AdditionalModules;
192+
193+ ImplicitImportInfo ()
194+ : StdlibKind(ImplicitStdlibKind::None),
195+ ShouldImportUnderlyingModule (false ) {}
196+ };
197+
161198class OverlayFile ;
162199
163200// / The minimum unit of compilation.
@@ -245,6 +282,10 @@ class ModuleDecl : public DeclContext, public TypeDecl {
245282 llvm::SmallDenseMap<Identifier, SmallVector<OverlayFile *, 1 >>
246283 declaredCrossImports;
247284
285+ // / A description of what should be implicitly imported by each file of this
286+ // / module.
287+ const ImplicitImportInfo ImportInfo;
288+
248289 std::unique_ptr<SourceLookupCache> Cache;
249290 SourceLookupCache &getSourceLookupCache () const ;
250291
@@ -274,15 +315,29 @@ class ModuleDecl : public DeclContext, public TypeDecl {
274315 // / \see EntryPointInfoTy
275316 EntryPointInfoTy EntryPointInfo;
276317
277- ModuleDecl (Identifier name, ASTContext &ctx);
318+ ModuleDecl (Identifier name, ASTContext &ctx, ImplicitImportInfo importInfo );
278319
279320public:
280- static ModuleDecl *create (Identifier name, ASTContext &ctx) {
281- return new (ctx) ModuleDecl (name, ctx);
321+ // / Creates a new module with a given \p name.
322+ // /
323+ // / \param importInfo Information about which modules should be implicitly
324+ // / imported by each file of this module.
325+ static ModuleDecl *
326+ create (Identifier name, ASTContext &ctx,
327+ ImplicitImportInfo importInfo = ImplicitImportInfo()) {
328+ return new (ctx) ModuleDecl (name, ctx, importInfo);
282329 }
283330
284331 using Decl::getASTContext;
285332
333+ // / Retrieves information about which modules are implicitly imported by
334+ // / each file of this module.
335+ const ImplicitImportInfo &getImplicitImportInfo () const { return ImportInfo; }
336+
337+ // / Retrieve a list of modules that each file of this module implicitly
338+ // / imports.
339+ ArrayRef<ImplicitImport> getImplicitImports () const ;
340+
286341 ArrayRef<FileUnit *> getFiles () {
287342 return Files;
288343 }
0 commit comments