diff options
author | Rui Ueyama <ruiu@google.com> | 2019-01-19 00:07:57 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2019-01-19 00:07:57 +0000 |
commit | 8e7600dc43cab3bf006e2b12d288687b2b323f1b (patch) | |
tree | 06d49ceb19c2748f64558c431058ff727493a05b /llvm/lib/Support/FileOutputBuffer.cpp | |
parent | f9d76dc354230152013b91b0526419a01855042e (diff) | |
download | bcm5719-llvm-8e7600dc43cab3bf006e2b12d288687b2b323f1b.tar.gz bcm5719-llvm-8e7600dc43cab3bf006e2b12d288687b2b323f1b.zip |
Remove F_modify flag from FileOutputBuffer.
This code is dead. There is no use of the feature in the entire LLVM codebase.
Differential Revision: https://reviews.llvm.org/D56939
llvm-svn: 351613
Diffstat (limited to 'llvm/lib/Support/FileOutputBuffer.cpp')
-rw-r--r-- | llvm/lib/Support/FileOutputBuffer.cpp | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/llvm/lib/Support/FileOutputBuffer.cpp b/llvm/lib/Support/FileOutputBuffer.cpp index b8223126227..b98152af9b2 100644 --- a/llvm/lib/Support/FileOutputBuffer.cpp +++ b/llvm/lib/Support/FileOutputBuffer.cpp @@ -116,30 +116,24 @@ createInMemoryBuffer(StringRef Path, size_t Size, unsigned Mode) { } static Expected<std::unique_ptr<OnDiskBuffer>> -createOnDiskBuffer(StringRef Path, size_t Size, bool InitExisting, - unsigned Mode) { +createOnDiskBuffer(StringRef Path, size_t Size, unsigned Mode) { Expected<fs::TempFile> FileOrErr = fs::TempFile::create(Path + ".tmp%%%%%%%", Mode); if (!FileOrErr) return FileOrErr.takeError(); fs::TempFile File = std::move(*FileOrErr); - if (InitExisting) { - if (auto EC = sys::fs::copy_file(Path, File.FD)) - return errorCodeToError(EC); - } else { #ifndef _WIN32 - // On Windows, CreateFileMapping (the mmap function on Windows) - // automatically extends the underlying file. We don't need to - // extend the file beforehand. _chsize (ftruncate on Windows) is - // pretty slow just like it writes specified amount of bytes, - // so we should avoid calling that function. - if (auto EC = fs::resize_file(File.FD, Size)) { - consumeError(File.discard()); - return errorCodeToError(EC); - } -#endif + // On Windows, CreateFileMapping (the mmap function on Windows) + // automatically extends the underlying file. We don't need to + // extend the file beforehand. _chsize (ftruncate on Windows) is + // pretty slow just like it writes specified amount of bytes, + // so we should avoid calling that function. + if (auto EC = fs::resize_file(File.FD, Size)) { + consumeError(File.discard()); + return errorCodeToError(EC); } +#endif // Mmap it. std::error_code EC; @@ -163,15 +157,6 @@ FileOutputBuffer::create(StringRef Path, size_t Size, unsigned Flags) { fs::file_status Stat; fs::status(Path, Stat); - if ((Flags & F_modify) && Size == size_t(-1)) { - if (Stat.type() == fs::file_type::regular_file) - Size = Stat.getSize(); - else if (Stat.type() == fs::file_type::file_not_found) - return errorCodeToError(errc::no_such_file_or_directory); - else - return errorCodeToError(errc::invalid_argument); - } - // Usually, we want to create OnDiskBuffer to create a temporary file in // the same directory as the destination file and atomically replaces it // by rename(2). @@ -186,7 +171,7 @@ FileOutputBuffer::create(StringRef Path, size_t Size, unsigned Flags) { case fs::file_type::regular_file: case fs::file_type::file_not_found: case fs::file_type::status_error: - return createOnDiskBuffer(Path, Size, !!(Flags & F_modify), Mode); + return createOnDiskBuffer(Path, Size, Mode); default: return createInMemoryBuffer(Path, Size, Mode); } |