Avoid memory mapping source files opened by SourceKit.

This commit is contained in:
Tristan Labelle
2023-11-01 11:33:33 -04:00
parent 5f3f845914
commit fb8c4182d3
2 changed files with 7 additions and 2 deletions

View File

@@ -884,8 +884,11 @@ SwiftASTManager::Implementation::getMemoryBuffer(
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
std::string &Error) const {
assert(FileSystem);
// Avoid memory-mapping as it could prevent the user from
// saving the file in the editor.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
FileSystem->getBufferForFile(Filename);
FileSystem->getBufferForFile(Filename, /*FileSize*/-1,
/*RequiresNullTerminator*/true, /*IsVolatile*/true);
if (FileBufOrErr)
return std::move(FileBufOrErr.get());