mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ModuleLoader: teach canImport to check Swift user module versions
For config condition `canImport(Foo, version: N)`, this patch teaches the compiler to check N against the version of the Swift module Foo on disk. It returns true if the module version on disk is greater or equal to N and returns false otherwise. Part of rdar://73992299
This commit is contained in:
@@ -250,7 +250,13 @@ public:
|
||||
/// Imports serialized Swift modules from a MemoryBuffer into an ASTContext.
|
||||
/// This interface is primarily used by LLDB.
|
||||
class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase {
|
||||
llvm::StringMap<std::unique_ptr<llvm::MemoryBuffer>> MemoryBuffers;
|
||||
|
||||
struct MemoryBufferInfo {
|
||||
std::unique_ptr<llvm::MemoryBuffer> buffer;
|
||||
llvm::VersionTuple userVersion;
|
||||
};
|
||||
|
||||
llvm::StringMap<MemoryBufferInfo> MemoryBuffers;
|
||||
|
||||
MemoryBufferSerializedModuleLoader(ASTContext &ctx,
|
||||
DependencyTracker *tracker,
|
||||
@@ -289,8 +295,9 @@ public:
|
||||
///
|
||||
/// FIXME: make this an actual import *path* once submodules are designed.
|
||||
void registerMemoryBuffer(StringRef importPath,
|
||||
std::unique_ptr<llvm::MemoryBuffer> input) {
|
||||
MemoryBuffers[importPath] = std::move(input);
|
||||
std::unique_ptr<llvm::MemoryBuffer> input,
|
||||
llvm::VersionTuple version) {
|
||||
MemoryBuffers[importPath] = {std::move(input), version};
|
||||
}
|
||||
|
||||
void collectVisibleTopLevelModuleNames(
|
||||
|
||||
Reference in New Issue
Block a user