File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
tools/SourceKit/lib/SwiftLang Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -938,11 +938,13 @@ CompilerInstance::getInputBuffersIfPresent(const InputFile &input) {
938
938
// FIXME: Working with filenames is fragile, maybe use the real path
939
939
// or have some kind of FileManager.
940
940
using FileOrError = llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>;
941
+ // Avoid memory-mapping when the compiler is run for IDE inspection,
942
+ // since that would prevent the user from saving the file.
941
943
FileOrError inputFileOrErr =
942
944
swift::vfs::getFileOrSTDIN (getFileSystem (), input.getFileName (),
943
945
/* FileSize*/ -1 ,
944
946
/* RequiresNullTerminator*/ true ,
945
- /* IsVolatile*/ false ,
947
+ /* IsVolatile*/ getInvocation (). isIDEInspection () ,
946
948
/* Bad File Descriptor Retry*/ getInvocation ().getFrontendOptions ()
947
949
.BadFileDescriptorRetryCount );
948
950
if (!inputFileOrErr) {
Original file line number Diff line number Diff line change @@ -884,8 +884,11 @@ SwiftASTManager::Implementation::getMemoryBuffer(
884
884
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
885
885
std::string &Error) const {
886
886
assert (FileSystem);
887
+ // Avoid memory-mapping as it could prevent the user from
888
+ // saving the file in the editor.
887
889
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
888
- FileSystem->getBufferForFile (Filename);
890
+ FileSystem->getBufferForFile (Filename, /* FileSize*/ -1 ,
891
+ /* RequiresNullTerminator*/ true , /* IsVolatile*/ true );
889
892
if (FileBufOrErr)
890
893
return std::move (FileBufOrErr.get ());
891
894
You can’t perform that action at this time.
0 commit comments