diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-05-05 21:57:46 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-05-05 21:57:46 +0000 |
commit | 26d56393c602df63526e878dbc5cca453601e9c5 (patch) | |
tree | 8b0369ca454315749ef93e13048368e10de04a93 | |
parent | 20a92ae3d2110ea6acbd9bbb3e9ecd2064bc34b5 (diff) | |
download | bcm5719-llvm-26d56393c602df63526e878dbc5cca453601e9c5.tar.gz bcm5719-llvm-26d56393c602df63526e878dbc5cca453601e9c5.zip |
[Basic/FileManager] Propagate whether a file 'IsVolatile' to the file opening functions.
Needs llvm r208007.
llvm-svn: 208008
-rw-r--r-- | clang/include/clang/Basic/VirtualFileSystem.h | 6 | ||||
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 14 |
3 files changed, 19 insertions, 10 deletions
diff --git a/clang/include/clang/Basic/VirtualFileSystem.h b/clang/include/clang/Basic/VirtualFileSystem.h index 5595e143bc2..f6307db9918 100644 --- a/clang/include/clang/Basic/VirtualFileSystem.h +++ b/clang/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<llvm::MemoryBuffer> &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<llvm::MemoryBuffer> &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/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 579c8185b3d..5d7d9390d29 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/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/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 9a88cfd3897..94a6c3dca6f 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -67,12 +67,14 @@ FileSystem::~FileSystem() {} error_code FileSystem::getBufferForFile(const llvm::Twine &Name, std::unique_ptr<MemoryBuffer> &Result, int64_t FileSize, - bool RequiresNullTerminator) { + bool RequiresNullTerminator, + bool IsVolatile) { std::unique_ptr<File> 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> status() override; error_code getBuffer(const Twine &Name, std::unique_ptr<MemoryBuffer> &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<Status> RealFile::status() { error_code RealFile::getBuffer(const Twine &Name, std::unique_ptr<MemoryBuffer> &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. |