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

@@ -938,11 +938,13 @@ CompilerInstance::getInputBuffersIfPresent(const InputFile &input) {
// FIXME: Working with filenames is fragile, maybe use the real path
// or have some kind of FileManager.
using FileOrError = llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>;
// Avoid memory-mapping when the compiler is run for IDE inspection,
// since that would prevent the user from saving the file.
FileOrError inputFileOrErr =
swift::vfs::getFileOrSTDIN(getFileSystem(), input.getFileName(),
/*FileSize*/-1,
/*RequiresNullTerminator*/true,
/*IsVolatile*/false,
/*IsVolatile*/getInvocation().isIDEInspection(),
/*Bad File Descriptor Retry*/getInvocation().getFrontendOptions()
.BadFileDescriptorRetryCount);
if (!inputFileOrErr) {