[Fast Dependency Scanner] Produce information on whether an explicit module is a framework

In the fast dependency scanner, depending on whether a module intrface was found via the import search path or framework search path, encode into the dependency graph Swift module details, whether a given module is a framework.
This commit is contained in:
Artem Chikin
2020-08-12 10:12:35 -07:00
parent 0d25abc2c4
commit 40c1687fd2
15 changed files with 117 additions and 54 deletions

View File

@@ -396,7 +396,7 @@ llvm::ErrorOr<ModuleDependencies> SerializedModuleLoaderBase::scanModuleFile(
&extInfo);
// Map the set of dependencies over to the "module dependencies".
auto dependencies = ModuleDependencies::forSwiftModule(modulePath.str());
auto dependencies = ModuleDependencies::forSwiftModule(modulePath.str(), isFramework);
llvm::StringSet<> addedModuleNames;
for (const auto &dependency : loadedModuleFile->getDependencies()) {
// FIXME: Record header dependency?
@@ -422,7 +422,8 @@ std::error_code ImplicitSerializedModuleLoader::findModuleFilesInDirectory(
SmallVectorImpl<char> *ModuleInterfacePath,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer) {
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
bool IsFramework) {
assert(((ModuleBuffer && ModuleDocBuffer) ||
(!ModuleBuffer && !ModuleDocBuffer)) &&
"Module and Module Doc buffer must both be initialized or NULL");
@@ -538,7 +539,7 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
/// Returns true if a target-specific module file was found, false if an error
/// was diagnosed, or None if neither one happened and the search should
/// continue.
auto findTargetSpecificModuleFiles = [&]() -> Optional<bool> {
auto findTargetSpecificModuleFiles = [&](bool IsFramework) -> Optional<bool> {
Optional<SerializedModuleBaseName> firstAbsoluteBaseName;
for (const auto &targetSpecificBaseName : targetSpecificBaseNames) {
@@ -552,7 +553,8 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
absoluteBaseName,
moduleInterfacePath,
moduleBuffer, moduleDocBuffer,
moduleSourceInfoBuffer);
moduleSourceInfoBuffer,
IsFramework);
if (!result) {
return true;
} else if (result == std::errc::not_supported) {
@@ -603,13 +605,13 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
if (checkTargetSpecificModule)
// A .swiftmodule directory contains architecture-specific files.
return findTargetSpecificModuleFiles();
return findTargetSpecificModuleFiles(isFramework);
SerializedModuleBaseName absoluteBaseName{currPath, genericBaseName};
auto result = findModuleFilesInDirectory(
moduleID, absoluteBaseName, moduleInterfacePath,
moduleBuffer, moduleDocBuffer, moduleSourceInfoBuffer);
moduleBuffer, moduleDocBuffer, moduleSourceInfoBuffer, isFramework);
if (!result)
return true;
else if (result == std::errc::not_supported)
@@ -628,7 +630,7 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
// Frameworks always use architecture-specific files within a
// .swiftmodule directory.
llvm::sys::path::append(currPath, "Modules");
return findTargetSpecificModuleFiles();
return findTargetSpecificModuleFiles(isFramework);
}
}
llvm_unreachable("covered switch");
@@ -1081,7 +1083,8 @@ std::error_code MemoryBufferSerializedModuleLoader::findModuleFilesInDirectory(
SmallVectorImpl<char> *ModuleInterfacePath,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer) {
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
bool IsFramework) {
// This is a soft error instead of an llvm_unreachable because this API is
// primarily used by LLDB which makes it more likely that unwitting changes to
// the Swift compiler accidentally break the contract.