mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ModuleInterface: refactor compiler instance configuration to a standalone delegate class. NFC
Module interface builder used to maintain a separate compiler instance for building Swift modules. The configuration of this compiler instance is also useful for dependencies scanner because it needs to emit front-end compiler invocation for building Swift modules explicitly. This patch refactor the configuration out to a delegate class, and the delegate class is also used by the dependency scanner.
This commit is contained in:
@@ -33,12 +33,13 @@ class ModuleDependencyScanner : public SerializedModuleLoaderBase {
|
||||
ErrorOr<ModuleDependencies> scanInterfaceFile(
|
||||
Twine moduleInterfacePath);
|
||||
|
||||
SubASTContextDelegate &astDelegate;
|
||||
InterfaceSubContextDelegate &astDelegate;
|
||||
public:
|
||||
Optional<ModuleDependencies> dependencies;
|
||||
|
||||
ModuleDependencyScanner(ASTContext &ctx, ModuleLoadingMode LoadMode,
|
||||
Identifier moduleName, SubASTContextDelegate &astDelegate)
|
||||
Identifier moduleName,
|
||||
InterfaceSubContextDelegate &astDelegate)
|
||||
: SerializedModuleLoaderBase(ctx, nullptr, LoadMode,
|
||||
/*IgnoreSwiftSourceInfoFile=*/true),
|
||||
moduleName(moduleName), astDelegate(astDelegate) { }
|
||||
@@ -104,9 +105,10 @@ ErrorOr<ModuleDependencies> ModuleDependencyScanner::scanInterfaceFile(
|
||||
ModuleDependencies Result = ModuleDependencies::forSwiftInterface(
|
||||
modulePath.str().str(), moduleInterfacePath.str());
|
||||
std::error_code code;
|
||||
auto hasError = astDelegate.runInSubContext(Ctx,
|
||||
moduleInterfacePath.str(),
|
||||
[&](ASTContext &Ctx) {
|
||||
auto hasError = astDelegate.runInSubContext(moduleName.str(),
|
||||
moduleInterfacePath.str(),
|
||||
StringRef(), SourceLoc(),
|
||||
[&](ASTContext &Ctx) {
|
||||
// Open the interface file.
|
||||
auto &fs = *Ctx.SourceMgr.getFileSystem();
|
||||
auto interfaceBuf = fs.getBufferForFile(moduleInterfacePath);
|
||||
@@ -135,7 +137,7 @@ ErrorOr<ModuleDependencies> ModuleDependencyScanner::scanInterfaceFile(
|
||||
|
||||
Optional<ModuleDependencies> SerializedModuleLoaderBase::getModuleDependencies(
|
||||
StringRef moduleName, ModuleDependenciesCache &cache,
|
||||
SubASTContextDelegate &delegate) {
|
||||
InterfaceSubContextDelegate &delegate) {
|
||||
// Check whether we've cached this result.
|
||||
if (auto found = cache.findDependencies(
|
||||
moduleName, ModuleDependenciesKind::Swift))
|
||||
|
||||
Reference in New Issue
Block a user