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

@@ -166,7 +166,9 @@ public:
///
/// Note that even if this check succeeds, errors may still occur if the
/// module is loaded in full.
virtual bool canImportModule(ImportPath::Element named) override;
virtual bool canImportModule(ImportPath::Element named,
llvm::VersionTuple version,
bool underlyingVersion) override;
/// Import a module with the given module path.
///
@@ -274,7 +276,8 @@ class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase {
public:
virtual ~MemoryBufferSerializedModuleLoader();
bool canImportModule(ImportPath::Element named) override;
bool canImportModule(ImportPath::Element named, llvm::VersionTuple version,
bool underlyingVersion) override;
ModuleDecl *
loadModule(SourceLoc importLoc,
ImportPath::Module path) override;