From f75f97a33aceda07015db4d49983979ceb527e5d Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 30 Aug 2019 16:56:26 +0000 Subject: [PATCH] FileManager: Remove ShouldCloseOpenFile argument from getBufferForFile, NFC Remove this dead code. We always close it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370488 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/FileManager.h | 3 +-- lib/Basic/FileManager.cpp | 8 ++------ lib/Serialization/ModuleManager.cpp | 4 +--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 2784a7ef52..a1d9bf765d 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -317,8 +317,7 @@ public: /// Open the specified file as a MemoryBuffer, returning a new /// MemoryBuffer if successful, otherwise returning null. llvm::ErrorOr> - getBufferForFile(const FileEntry *Entry, bool isVolatile = false, - bool ShouldCloseOpenFile = true); + getBufferForFile(const FileEntry *Entry, bool isVolatile = false); llvm::ErrorOr> getBufferForFile(StringRef Filename, bool isVolatile = false) { return getBufferForFileImpl(Filename, /*FileSize=*/-1, isVolatile); diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index ec9ada2f19..4330c7ac61 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -426,8 +426,7 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) { } llvm::ErrorOr> -FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile, - bool ShouldCloseOpenFile) { +FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile) { uint64_t FileSize = Entry->getSize(); // If there's a high enough chance that the file have changed since we // got its size, force a stat before opening it. @@ -440,10 +439,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile, auto Result = Entry->File->getBuffer(Filename, FileSize, /*RequiresNullTerminator=*/true, isVolatile); - // FIXME: we need a set of APIs that can make guarantees about whether a - // FileEntry is open or not. - if (ShouldCloseOpenFile) - Entry->closeFile(); + Entry->closeFile(); return Result; } diff --git a/lib/Serialization/ModuleManager.cpp b/lib/Serialization/ModuleManager.cpp index 878ee46382..4b9f20fca4 100644 --- a/lib/Serialization/ModuleManager.cpp +++ b/lib/Serialization/ModuleManager.cpp @@ -185,9 +185,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, Buf = llvm::MemoryBuffer::getSTDIN(); } else { // Get a buffer of the file and close the file descriptor when done. - Buf = FileMgr.getBufferForFile(NewModule->File, - /*isVolatile=*/false, - /*ShouldClose=*/true); + Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false); } if (!Buf) { -- 2.40.0