Parser: teach canImport to take an additional parameter indicating the minimum module version

canImport should be able to take an additional parameter labeled by either version or
underlyingVersion. We need underlyingVersion for clang modules with Swift overlays because they
have separate version numbers. The library users are usually interested in checking the importability
of the underlying clang module instead of its Swift overlay.

Part of rdar://73992299
This commit is contained in:
Xi Ge
2021-05-01 23:51:26 -07:00
parent d38b23346f
commit bbe5b83de9
15 changed files with 145 additions and 28 deletions

View File

@@ -948,7 +948,7 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
}
bool SerializedModuleLoaderBase::canImportModule(
ImportPath::Element mID) {
ImportPath::Element mID, llvm::VersionTuple version, bool underlyingVersion) {
// Look on disk.
SmallVector<char, 0> *unusedModuleInterfacePath = nullptr;
std::unique_ptr<llvm::MemoryBuffer> *unusedModuleBuffer = nullptr;
@@ -962,7 +962,7 @@ bool SerializedModuleLoaderBase::canImportModule(
}
bool MemoryBufferSerializedModuleLoader::canImportModule(
ImportPath::Element mID) {
ImportPath::Element mID, llvm::VersionTuple version, bool underlyingVersion) {
// See if we find it in the registered memory buffers.
return MemoryBuffers.count(mID.Item.str());
}