summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/MemoryBuffer.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-06-07 19:58:58 +0000
committerZachary Turner <zturner@google.com>2018-06-07 19:58:58 +0000
commit1f67a3cba9b09636c56e2109d8a35ae96dc15782 (patch)
treec6ebd0cdd45f18a50b4bee970dc71809b9cb3570 /llvm/lib/Support/MemoryBuffer.cpp
parent84be76133282f8bd66820ca93402a741c0ee632e (diff)
downloadbcm5719-llvm-1f67a3cba9b09636c56e2109d8a35ae96dc15782.tar.gz
bcm5719-llvm-1f67a3cba9b09636c56e2109d8a35ae96dc15782.zip
[FileSystem] Split up the OpenFlags enumeration.
This breaks the OpenFlags enumeration into two separate enumerations: OpenFlags and CreationDisposition. The first controls the behavior of the API depending on whether or not the target file already exists, and is not a flags-based enum. The second controls more flags-like values. This yields a more easy to understand API, while also allowing flags to be passed to the openForRead api, where most of the values didn't make sense before. This also makes the apis more testable as it becomes easy to enumerate all the configurations which make sense, so I've added many new tests to exercise all the different values. llvm-svn: 334221
Diffstat (limited to 'llvm/lib/Support/MemoryBuffer.cpp')
-rw-r--r--llvm/lib/Support/MemoryBuffer.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp
index fe04bb6fb57..d8cc853f2a8 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -244,7 +244,7 @@ static ErrorOr<std::unique_ptr<MB>>
getFileAux(const Twine &Filename, int64_t FileSize, uint64_t MapSize,
uint64_t Offset, bool RequiresNullTerminator, bool IsVolatile) {
int FD;
- std::error_code EC = sys::fs::openFileForRead(Filename, FD);
+ std::error_code EC = sys::fs::openFileForRead(Filename, FD, sys::fs::OF_None);
if (EC)
return EC;
@@ -364,8 +364,8 @@ static ErrorOr<std::unique_ptr<WriteThroughMemoryBuffer>>
getReadWriteFile(const Twine &Filename, uint64_t FileSize, uint64_t MapSize,
uint64_t Offset) {
int FD;
- std::error_code EC = sys::fs::openFileForWrite(
- Filename, FD, sys::fs::F_RW | sys::fs::F_NoTrunc);
+ std::error_code EC = sys::fs::openFileForReadWrite(
+ Filename, FD, sys::fs::CD_OpenExisting, sys::fs::OF_None);
if (EC)
return EC;
@@ -518,7 +518,7 @@ ErrorOr<std::unique_ptr<MemoryBuffer>> MemoryBuffer::getSTDIN() {
ErrorOr<std::unique_ptr<MemoryBuffer>>
MemoryBuffer::getFileAsStream(const Twine &Filename) {
int FD;
- std::error_code EC = sys::fs::openFileForRead(Filename, FD);
+ std::error_code EC = sys::fs::openFileForRead(Filename, FD, sys::fs::OF_None);
if (EC)
return EC;
ErrorOr<std::unique_ptr<MemoryBuffer>> Ret =
OpenPOWER on IntegriCloud