Refactor 'ModuleInterfaceBuilder' to separate CompilerInstance setup logic from compilation logic (moved to ExplicitModuleInterfaceBuilder).

This commit is contained in:
Artem Chikin
2022-08-04 14:40:09 -07:00
parent e5a35f9819
commit 7fd2a29fb7
11 changed files with 413 additions and 319 deletions

View File

@@ -300,7 +300,6 @@ struct ModuleInterfaceLoaderOptions {
bool disableImplicitSwiftModule = false;
bool disableBuildingInterface = false;
bool downgradeInterfaceVerificationError = false;
bool ignoreInterfaceProvidedOptions = false;
std::string mainExecutablePath;
ModuleInterfaceLoaderOptions(const FrontendOptions &Opts):
remarkOnRebuildFromInterface(Opts.RemarkOnRebuildFromModuleInterface),
@@ -308,7 +307,6 @@ struct ModuleInterfaceLoaderOptions {
disableImplicitSwiftModule(Opts.DisableImplicitModules),
disableBuildingInterface(Opts.DisableBuildingInterface),
downgradeInterfaceVerificationError(Opts.DowngradeInterfaceVerificationError),
ignoreInterfaceProvidedOptions(Opts.IgnoreInterfaceProvidedOptions),
mainExecutablePath(Opts.MainExecutablePath)
{
switch (Opts.RequestedAction) {
@@ -442,6 +440,21 @@ public:
bool SerializeDependencyHashes,
bool TrackSystemDependencies, ModuleInterfaceLoaderOptions Opts,
RequireOSSAModules_t RequireOSSAModules);
/// Unconditionally build \p InPath (a swiftinterface file) to \p OutPath (as
/// a swiftmodule file).
///
/// Unlike the above `buildSwiftModuleFromSwiftInterface`, this method
/// bypasses the instantiation of a `CompilerInstance` from the compiler
/// configuration flags in the interface and instead directly uses the
/// supplied \p Instance
static bool buildExplicitSwiftModuleFromSwiftInterface(
CompilerInstance &Instance, const StringRef moduleCachePath,
const StringRef backupInterfaceDir, const StringRef prebuiltCachePath,
const StringRef ABIDescriptorPath, StringRef interfacePath,
StringRef outputPath, bool ShouldSerializeDeps,
ArrayRef<std::string> CompiledCandidates, StringRef CompilerVersion,
DependencyTracker *tracker = nullptr);
};
struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate {
@@ -476,8 +489,7 @@ private:
SmallVectorImpl<const char *> &SubArgs,
std::string &CompilerVersion,
StringRef interfacePath,
SourceLoc diagnosticLoc,
bool ignoreInterfaceProvidedOptions);
SourceLoc diagnosticLoc);
public:
InterfaceSubContextDelegateImpl(
SourceManager &SM, DiagnosticEngine *Diags,
@@ -492,7 +504,6 @@ public:
StringRef interfacePath,
StringRef outputPath,
SourceLoc diagLoc,
bool ignoreInterfaceProvidedOptions,
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*,
ArrayRef<StringRef>, ArrayRef<StringRef>,
StringRef)> action) override;
@@ -500,7 +511,6 @@ public:
StringRef interfacePath,
StringRef outputPath,
SourceLoc diagLoc,
bool ignoreInterfaceProvidedOptions,
llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) override;
~InterfaceSubContextDelegateImpl() = default;