[LLDB] Add an API for unregistering MemoryBuffer modules (NFC)

This commit is contained in:
Adrian Prantl
2025-11-12 17:24:36 -08:00
parent d704461048
commit addff767a6
2 changed files with 21 additions and 5 deletions

View File

@@ -373,11 +373,14 @@ public:
/// FIXME: make this an actual import *path* once submodules are designed.
bool registerMemoryBuffer(StringRef importPath,
std::unique_ptr<llvm::MemoryBuffer> input,
llvm::VersionTuple version) {
return MemoryBuffers
.insert({importPath, MemoryBufferInfo(std::move(input), version)})
.second;
}
llvm::VersionTuple version);
/// During the transtion to explicitly tracked module dependencies LLDB may
/// instruct this loader to forget one of the (now redundant) MemoryBuffers
/// because it found an explicit module file on disk.
///
/// \return true if the importPath existed.
bool unregisterMemoryBuffer(StringRef importPath);
void collectVisibleTopLevelModuleNames(
SmallVectorImpl<Identifier> &names) const override {}

View File

@@ -1708,6 +1708,19 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
return M;
}
bool MemoryBufferSerializedModuleLoader::registerMemoryBuffer(
StringRef importPath, std::unique_ptr<llvm::MemoryBuffer> input,
llvm::VersionTuple version) {
return MemoryBuffers
.insert({importPath, MemoryBufferInfo(std::move(input), version)})
.second;
}
bool MemoryBufferSerializedModuleLoader::unregisterMemoryBuffer(
StringRef importPath) {
return MemoryBuffers.erase(importPath);
}
void SerializedModuleLoaderBase::loadExtensions(NominalTypeDecl *nominal,
unsigned previousGeneration) {
for (auto &modulePair : LoadedModuleFiles) {