浏览代码

[FileSystem] Remove OpenFlags param from several functions.

There was only one place in the entire codebase where a non
default value was being passed, and that place was already hidden
in an implementation file.  So we can delete the extra parameter
and all existing clients continue to work as they always have,
while making the interface a bit simpler.

Differential Revision: https://reviews.llvm.org/D47789

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334046 91177308-0d34-0410-b5e6-96231b3b80d8
Zachary Turner 7 年之前
父节点
当前提交
ceb8b5d24a
共有 2 个文件被更改,包括 18 次插入18 次删除
  1. 2 4
      include/llvm/Support/FileSystem.h
  2. 16 14
      lib/Support/Path.cpp

+ 2 - 4
include/llvm/Support/FileSystem.h

@@ -727,8 +727,7 @@ enum OpenFlags : unsigned {
 ///          otherwise a platform-specific error_code.
 ///          otherwise a platform-specific error_code.
 std::error_code createUniqueFile(const Twine &Model, int &ResultFD,
 std::error_code createUniqueFile(const Twine &Model, int &ResultFD,
                                  SmallVectorImpl<char> &ResultPath,
                                  SmallVectorImpl<char> &ResultPath,
-                                 unsigned Mode = all_read | all_write,
-                                 sys::fs::OpenFlags Flags = sys::fs::F_RW);
+                                 unsigned Mode = all_read | all_write);
 
 
 /// Simpler version for clients that don't want an open file. An empty
 /// Simpler version for clients that don't want an open file. An empty
 /// file will still be created.
 /// file will still be created.
@@ -784,8 +783,7 @@ public:
 /// running the assembler.
 /// running the assembler.
 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
                                     int &ResultFD,
                                     int &ResultFD,
-                                    SmallVectorImpl<char> &ResultPath,
-                                    sys::fs::OpenFlags Flags = sys::fs::F_RW);
+                                    SmallVectorImpl<char> &ResultPath);
 
 
 /// Simpler version for clients that don't want an open file. An empty
 /// Simpler version for clients that don't want an open file. An empty
 /// file will still be created.
 /// file will still be created.

+ 16 - 14
lib/Support/Path.cpp

@@ -169,7 +169,7 @@ static std::error_code
 createUniqueEntity(const Twine &Model, int &ResultFD,
 createUniqueEntity(const Twine &Model, int &ResultFD,
                    SmallVectorImpl<char> &ResultPath, bool MakeAbsolute,
                    SmallVectorImpl<char> &ResultPath, bool MakeAbsolute,
                    unsigned Mode, FSEntity Type,
                    unsigned Mode, FSEntity Type,
-                   sys::fs::OpenFlags Flags = sys::fs::F_None) {
+                   sys::fs::OpenFlags Flags = sys::fs::F_RW) {
   SmallString<128> ModelStorage;
   SmallString<128> ModelStorage;
   Model.toVector(ModelStorage);
   Model.toVector(ModelStorage);
 
 
@@ -756,7 +756,13 @@ std::error_code getUniqueID(const Twine Path, UniqueID &Result) {
 
 
 std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
 std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
                                  SmallVectorImpl<char> &ResultPath,
                                  SmallVectorImpl<char> &ResultPath,
-                                 unsigned Mode, sys::fs::OpenFlags Flags) {
+                                 unsigned Mode) {
+  return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, FS_File);
+}
+
+static std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
+                                        SmallVectorImpl<char> &ResultPath,
+                                        unsigned Mode, OpenFlags Flags) {
   return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, FS_File,
   return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, FS_File,
                             Flags);
                             Flags);
 }
 }
@@ -775,32 +781,28 @@ std::error_code createUniqueFile(const Twine &Model,
 
 
 static std::error_code
 static std::error_code
 createTemporaryFile(const Twine &Model, int &ResultFD,
 createTemporaryFile(const Twine &Model, int &ResultFD,
-                    llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type,
-                    sys::fs::OpenFlags Flags) {
+                    llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type) {
   SmallString<128> Storage;
   SmallString<128> Storage;
   StringRef P = Model.toNullTerminatedStringRef(Storage);
   StringRef P = Model.toNullTerminatedStringRef(Storage);
   assert(P.find_first_of(separators(Style::native)) == StringRef::npos &&
   assert(P.find_first_of(separators(Style::native)) == StringRef::npos &&
          "Model must be a simple filename.");
          "Model must be a simple filename.");
   // Use P.begin() so that createUniqueEntity doesn't need to recreate Storage.
   // Use P.begin() so that createUniqueEntity doesn't need to recreate Storage.
   return createUniqueEntity(P.begin(), ResultFD, ResultPath, true,
   return createUniqueEntity(P.begin(), ResultFD, ResultPath, true,
-                            owner_read | owner_write, Type, Flags);
+                            owner_read | owner_write, Type);
 }
 }
 
 
 static std::error_code
 static std::error_code
 createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD,
 createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD,
-                    llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type,
-                    sys::fs::OpenFlags Flags = sys::fs::F_None) {
+                    llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type) {
   const char *Middle = Suffix.empty() ? "-%%%%%%" : "-%%%%%%.";
   const char *Middle = Suffix.empty() ? "-%%%%%%" : "-%%%%%%.";
   return createTemporaryFile(Prefix + Middle + Suffix, ResultFD, ResultPath,
   return createTemporaryFile(Prefix + Middle + Suffix, ResultFD, ResultPath,
-                             Type, Flags);
+                             Type);
 }
 }
 
 
 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
                                     int &ResultFD,
                                     int &ResultFD,
-                                    SmallVectorImpl<char> &ResultPath,
-                                    sys::fs::OpenFlags Flags) {
-  return createTemporaryFile(Prefix, Suffix, ResultFD, ResultPath, FS_File,
-                             Flags);
+                                    SmallVectorImpl<char> &ResultPath) {
+  return createTemporaryFile(Prefix, Suffix, ResultFD, ResultPath, FS_File);
 }
 }
 
 
 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
 std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
@@ -1177,8 +1179,8 @@ Error TempFile::keep() {
 Expected<TempFile> TempFile::create(const Twine &Model, unsigned Mode) {
 Expected<TempFile> TempFile::create(const Twine &Model, unsigned Mode) {
   int FD;
   int FD;
   SmallString<128> ResultPath;
   SmallString<128> ResultPath;
-  if (std::error_code EC = createUniqueFile(Model, FD, ResultPath, Mode,
-                                            sys::fs::F_RW | sys::fs::F_Delete))
+  if (std::error_code EC =
+          createUniqueFile(Model, FD, ResultPath, Mode, F_Delete | F_RW))
     return errorCodeToError(EC);
     return errorCodeToError(EC);
 
 
   TempFile Ret(ResultPath, FD);
   TempFile Ret(ResultPath, FD);