Define the semantics of registerMemoryBuffer() when insterting duplicates

to let the first module win. This functionality is tested in LLDB.
This commit is contained in:
Adrian Prantl
2024-04-19 16:24:34 -07:00
parent 5022da8324
commit c95f403f86

View File

@@ -315,6 +315,9 @@ public:
class MemoryBufferSerializedModuleLoader : public SerializedModuleLoaderBase {
struct MemoryBufferInfo {
MemoryBufferInfo(std::unique_ptr<llvm::MemoryBuffer> &&buffer,
llvm::VersionTuple userVersion)
: buffer(std::move(buffer)), userVersion(userVersion) {}
std::unique_ptr<llvm::MemoryBuffer> buffer;
llvm::VersionTuple userVersion;
};
@@ -363,11 +366,16 @@ public:
/// discovered in the __swift_ast section of a Mach-O file (or the .swift_ast
/// section of an ELF file) to the search path.
///
/// If a module is inserted twice, the first one wins, and the return value is
/// false.
///
/// FIXME: make this an actual import *path* once submodules are designed.
void registerMemoryBuffer(StringRef importPath,
bool registerMemoryBuffer(StringRef importPath,
std::unique_ptr<llvm::MemoryBuffer> input,
llvm::VersionTuple version) {
MemoryBuffers[importPath] = {std::move(input), version};
return MemoryBuffers
.insert({importPath, MemoryBufferInfo(std::move(input), version)})
.second;
}
void collectVisibleTopLevelModuleNames(