@@ -311,20 +311,40 @@ struct ModuleInterfaceLoaderOptions {
311311 ModuleInterfaceLoaderOptions () = default ;
312312};
313313
314+ // / Strongly typed enum that represents if we require all SILModules to have
315+ // / OSSA modules emitted. This is implemented by incorporating this bit into the
316+ // / module cache hash.
317+ struct RequireOSSAModules_t {
318+ enum ValueTy {
319+ No = 0 ,
320+ Yes = 1 ,
321+ };
322+
323+ ValueTy value;
324+
325+ RequireOSSAModules_t (const SILOptions &opts)
326+ : value(opts.EnableOSSAModules ? RequireOSSAModules_t::Yes
327+ : RequireOSSAModules_t::No) {}
328+
329+ operator ValueTy () const { return value; }
330+ explicit operator bool () const { return bool (value); }
331+ };
332+
314333class ModuleInterfaceCheckerImpl : public ModuleInterfaceChecker {
315334 friend class ModuleInterfaceLoader ;
316335 ASTContext &Ctx;
317336 std::string CacheDir;
318337 std::string PrebuiltCacheDir;
319338 ModuleInterfaceLoaderOptions Opts;
339+ RequireOSSAModules_t RequiresOSSAModules;
320340
321341public:
322- explicit ModuleInterfaceCheckerImpl (ASTContext &Ctx,
323- StringRef cacheDir,
342+ explicit ModuleInterfaceCheckerImpl (ASTContext &Ctx, StringRef cacheDir,
324343 StringRef prebuiltCacheDir,
325- ModuleInterfaceLoaderOptions Opts)
326- : Ctx(Ctx), CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
327- Opts(Opts) {}
344+ ModuleInterfaceLoaderOptions opts,
345+ RequireOSSAModules_t requiresOSSAModules)
346+ : Ctx(Ctx), CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
347+ Opts(opts), RequiresOSSAModules(requiresOSSAModules) {}
328348
329349 std::vector<std::string>
330350 getCompiledModuleCandidatesForInterface (StringRef moduleName,
@@ -390,13 +410,13 @@ class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
390410 // /
391411 // / A simplified version of the core logic in #openModuleFiles.
392412 static bool buildSwiftModuleFromSwiftInterface (
393- SourceManager &SourceMgr, DiagnosticEngine &Diags,
394- const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
395- const ClangImporterOptions &ClangOpts,
396- StringRef CacheDir , StringRef PrebuiltCacheDir ,
397- StringRef ModuleName, StringRef InPath, StringRef OutPath ,
398- bool SerializeDependencyHashes, bool TrackSystemDependencies,
399- ModuleInterfaceLoaderOptions Opts );
413+ SourceManager &SourceMgr, DiagnosticEngine &Diags,
414+ const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
415+ const ClangImporterOptions &ClangOpts, StringRef CacheDir ,
416+ StringRef PrebuiltCacheDir , StringRef ModuleName, StringRef InPath ,
417+ StringRef OutPath, bool SerializeDependencyHashes ,
418+ bool TrackSystemDependencies, ModuleInterfaceLoaderOptions Opts ,
419+ RequireOSSAModules_t RequireOSSAModules );
400420};
401421
402422struct InterfaceSubContextDelegateImpl : InterfaceSubContextDelegate {
@@ -420,25 +440,24 @@ struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate {
420440 }
421441 return Diags.diagnose (loc, ID, std::move (Args)...);
422442 }
423- void inheritOptionsForBuildingInterface (const SearchPathOptions &SearchPathOpts,
424- const LangOptions &LangOpts);
443+ void
444+ inheritOptionsForBuildingInterface (const SearchPathOptions &SearchPathOpts,
445+ const LangOptions &LangOpts,
446+ RequireOSSAModules_t requireOSSAModules);
425447 bool extractSwiftInterfaceVersionAndArgs (CompilerInvocation &subInvocation,
426448 SmallVectorImpl<const char *> &SubArgs,
427449 std::string &CompilerVersion,
428450 StringRef interfacePath,
429451 SourceLoc diagnosticLoc);
430452public:
431- InterfaceSubContextDelegateImpl (SourceManager &SM,
432- DiagnosticEngine &Diags,
433- const SearchPathOptions &searchPathOpts,
434- const LangOptions &langOpts,
435- const ClangImporterOptions &clangImporterOpts,
436- ModuleInterfaceLoaderOptions LoaderOpts,
437- bool buildModuleCacheDirIfAbsent,
438- StringRef moduleCachePath,
439- StringRef prebuiltCachePath,
440- bool serializeDependencyHashes,
441- bool trackSystemDependencies);
453+ InterfaceSubContextDelegateImpl (
454+ SourceManager &SM, DiagnosticEngine &Diags,
455+ const SearchPathOptions &searchPathOpts, const LangOptions &langOpts,
456+ const ClangImporterOptions &clangImporterOpts,
457+ ModuleInterfaceLoaderOptions LoaderOpts, bool buildModuleCacheDirIfAbsent,
458+ StringRef moduleCachePath, StringRef prebuiltCachePath,
459+ bool serializeDependencyHashes, bool trackSystemDependencies,
460+ RequireOSSAModules_t requireOSSAModules);
442461 std::error_code runInSubContext (StringRef moduleName,
443462 StringRef interfacePath,
444463 StringRef outputPath,
0 commit comments