[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:
Jordan Rose
2018-06-13 16:17:27 -07:00
parent a18dc118be
commit 07b200130f
4 changed files with 28 additions and 1 deletions

View File

@@ -29,6 +29,8 @@ private:
using LoadedModulePair = std::pair<std::unique_ptr<ModuleFile>, unsigned>;
std::vector<LoadedModulePair> LoadedModuleFiles;
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 2> OrphanedMemoryBuffers;
explicit SerializedModuleLoader(ASTContext &ctx, DependencyTracker *tracker);
public: