mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Keep buffers alive if they may have diagnostics
This can only happen in one case today: a module imports a bridging header, but the header on disk has disappeared, and now we need to fall back to the (often inadequate) version that's stored inside the swiftmodule file. Even if the module fails to load, the bridging header has already been imported, and so anything else that happens might still emit diagnostics and need that text to be alive, which means we need to keep the buffer alive too.
This commit is contained in:
@@ -1457,6 +1457,17 @@ Status ModuleFile::associateWithFileContext(FileUnit *file,
|
||||
return getStatus();
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::MemoryBuffer> ModuleFile::takeBufferForDiagnostics() {
|
||||
assert(getStatus() != Status::Valid);
|
||||
|
||||
// Today, the only buffer that might have diagnostics in them is the input
|
||||
// buffer, and even then only if it has imported module contents.
|
||||
if (!importedHeaderInfo.contents.empty())
|
||||
return std::move(ModuleInputBuffer);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ModuleFile::~ModuleFile() { }
|
||||
|
||||
void ModuleFile::lookupValue(DeclName name,
|
||||
|
||||
Reference in New Issue
Block a user