Skip to content

Commit ac3f9f8

Browse files
committed
[sourcekitd-test] Don't cache memory buffers
If we cache the buffers between multiple requests we don’t pick up if the source file has changed on disk since we last read it.
1 parent d87700d commit ac3f9f8

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,8 +2655,6 @@ static unsigned resolveFromLineCol(unsigned Line, unsigned Col,
26552655
exit(1);
26562656
}
26572657

2658-
static llvm::StringMap<llvm::MemoryBuffer*> Buffers;
2659-
26602658
/// Opens \p Filename, first checking \p VFSFiles and then falling back to the
26612659
/// filesystem otherwise. If the file could not be opened and \p ExitOnError is
26622660
/// true, the process exits with an error message. Otherwise a buffer
@@ -2669,10 +2667,6 @@ getBufferForFilename(StringRef Filename,
26692667
auto MappedFilename =
26702668
VFSFileIt == VFSFiles.end() ? Filename : StringRef(VFSFileIt->second.path);
26712669

2672-
auto It = Buffers.find(MappedFilename);
2673-
if (It != Buffers.end())
2674-
return It->second;
2675-
26762670
auto FileBufOrErr = llvm::MemoryBuffer::getFile(MappedFilename);
26772671
std::unique_ptr<llvm::MemoryBuffer> Buffer;
26782672
if (!FileBufOrErr) {
@@ -2687,5 +2681,5 @@ getBufferForFilename(StringRef Filename,
26872681
Buffer = std::move(FileBufOrErr.get());
26882682
}
26892683

2690-
return Buffers[MappedFilename] = Buffer.release();
2684+
return Buffer.release();
26912685
}

0 commit comments

Comments
 (0)