From: Argyrios Kyrtzidis Date: Mon, 5 May 2014 21:57:46 +0000 (+0000) Subject: [Basic/FileManager] Propagate whether a file 'IsVolatile' to the file opening functions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd80493223a2507f989add766fe27aa72a787d5a;p=clang [Basic/FileManager] Propagate whether a file 'IsVolatile' to the file opening functions. Needs llvm r208007. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208008 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h index 5595e143bc..f6307db991 100644 --- a/include/clang/Basic/VirtualFileSystem.h +++ b/include/clang/Basic/VirtualFileSystem.h @@ -86,7 +86,8 @@ public: /// \brief Get the contents of the file as a \p MemoryBuffer. virtual llvm::error_code getBuffer(const Twine &Name, std::unique_ptr &Result, - int64_t FileSize = -1, bool RequiresNullTerminator = true) = 0; + int64_t FileSize = -1, bool RequiresNullTerminator = true, + bool IsVolatile = false) = 0; /// \brief Closes the file. virtual llvm::error_code close() = 0; /// \brief Sets the name to use for this file. @@ -109,7 +110,8 @@ public: llvm::error_code getBufferForFile(const Twine &Name, std::unique_ptr &Result, int64_t FileSize = -1, - bool RequiresNullTerminator = true); + bool RequiresNullTerminator = true, + bool IsVolatile = false); }; /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 579c8185b3..5d7d9390d2 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -391,7 +391,8 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, const char *Filename = Entry->getName(); // If the file is already open, use the open file descriptor. if (Entry->File) { - ec = Entry->File->getBuffer(Filename, Result, FileSize); + ec = Entry->File->getBuffer(Filename, Result, FileSize, + /*RequiresNullTerminator=*/true, isVolatile); if (ErrorStr) *ErrorStr = ec.message(); Entry->closeFile(); @@ -401,7 +402,8 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, // Otherwise, open the file. if (FileSystemOpts.WorkingDir.empty()) { - ec = FS->getBufferForFile(Filename, Result, FileSize); + ec = FS->getBufferForFile(Filename, Result, FileSize, + /*RequiresNullTerminator=*/true, isVolatile); if (ec && ErrorStr) *ErrorStr = ec.message(); return Result.release(); @@ -409,7 +411,8 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, SmallString<128> FilePath(Entry->getName()); FixupRelativePath(FilePath); - ec = FS->getBufferForFile(FilePath.str(), Result, FileSize); + ec = FS->getBufferForFile(FilePath.str(), Result, FileSize, + /*RequiresNullTerminator=*/true, isVolatile); if (ec && ErrorStr) *ErrorStr = ec.message(); return Result.release(); diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index 9a88cfd389..94a6c3dca6 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -67,12 +67,14 @@ FileSystem::~FileSystem() {} error_code FileSystem::getBufferForFile(const llvm::Twine &Name, std::unique_ptr &Result, int64_t FileSize, - bool RequiresNullTerminator) { + bool RequiresNullTerminator, + bool IsVolatile) { std::unique_ptr F; if (error_code EC = openFileForRead(Name, F)) return EC; - error_code EC = F->getBuffer(Name, Result, FileSize, RequiresNullTerminator); + error_code EC = F->getBuffer(Name, Result, FileSize, RequiresNullTerminator, + IsVolatile); return EC; } @@ -95,7 +97,8 @@ public: ErrorOr status() override; error_code getBuffer(const Twine &Name, std::unique_ptr &Result, int64_t FileSize = -1, - bool RequiresNullTerminator = true) override; + bool RequiresNullTerminator = true, + bool IsVolatile = false) override; error_code close() override; void setName(StringRef Name) override; }; @@ -117,10 +120,11 @@ ErrorOr RealFile::status() { error_code RealFile::getBuffer(const Twine &Name, std::unique_ptr &Result, - int64_t FileSize, bool RequiresNullTerminator) { + int64_t FileSize, bool RequiresNullTerminator, + bool IsVolatile) { assert(FD != -1 && "cannot get buffer for closed file"); return MemoryBuffer::getOpenFile(FD, Name.str().c_str(), Result, FileSize, - RequiresNullTerminator); + RequiresNullTerminator, IsVolatile); } // FIXME: This is terrible, we need this for ::close.