mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Avoid memory mapping source files opened by SourceKit.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user