Skip to content

Commit 7e70389

Browse files
committed
[upstream-update] Do not specify OpenFlags since it was removed upstream.
This was removed upstream in https://reviews.llvm.org/D47789 since the only place this flag was used was in the windows implementation where the behavior triggered by this could be hidden in the implementation instead of being an argument. As such, this code doesn't compile on master-next. Since this has an acceptable default argument given the current stable, we can just fix this on master and everything will work. rdar://42862352
1 parent 99b1ce7 commit 7e70389

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

Diff for: include/swift/Basic/FileSystem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace swift {
4545
/// As a special case, an output path of "-" is treated as referring to
4646
/// stdout.
4747
std::error_code atomicallyWritingToFile(
48-
llvm::StringRef outputPath, bool binaryMode,
48+
llvm::StringRef outputPath,
4949
llvm::function_ref<void(llvm::raw_pwrite_stream &)> action);
5050

5151
/// Moves a file from \p source to \p destination, unless there is already

Diff for: lib/Basic/FileSystem.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ canUseTemporaryForWrite(const StringRef outputPath) {
7979
/// temporary file that was just created.
8080
/// \param outputPath The path to the final output file, which is used to decide
8181
/// where to put the temporary.
82-
/// \param openFlags Controls how the output stream will be opened.
8382
///
8483
/// \returns The path to the temporary file that was opened, or \c None if the
8584
/// file couldn't be created.
8685
static Optional<std::string>
8786
tryToOpenTemporaryFile(Optional<llvm::raw_fd_ostream> &openedStream,
88-
const StringRef outputPath,
89-
const llvm::sys::fs::OpenFlags openFlags) {
87+
const StringRef outputPath) {
9088
namespace fs = llvm::sys::fs;
9189

9290
// Create a temporary file path.
@@ -102,8 +100,7 @@ tryToOpenTemporaryFile(Optional<llvm::raw_fd_ostream> &openedStream,
102100

103101
int fd;
104102
const unsigned perms = fs::all_read | fs::all_write;
105-
std::error_code EC = fs::createUniqueFile(tempPath, fd, tempPath, perms,
106-
openFlags);
103+
std::error_code EC = fs::createUniqueFile(tempPath, fd, tempPath, perms);
107104

108105
if (EC) {
109106
// Ignore the specific error; the caller has to fall back to not using a
@@ -118,7 +115,7 @@ tryToOpenTemporaryFile(Optional<llvm::raw_fd_ostream> &openedStream,
118115
}
119116

120117
std::error_code swift::atomicallyWritingToFile(
121-
const StringRef outputPath, const bool binaryMode,
118+
const StringRef outputPath,
122119
const llvm::function_ref<void(llvm::raw_pwrite_stream &)> action) {
123120
namespace fs = llvm::sys::fs;
124121

@@ -133,11 +130,9 @@ std::error_code swift::atomicallyWritingToFile(
133130

134131
Optional<std::string> temporaryPath;
135132
{
136-
const fs::OpenFlags openFlags = (binaryMode ? fs::F_None : fs::F_Text);
137-
138133
Optional<llvm::raw_fd_ostream> OS;
139134
if (canUseTemporary.get()) {
140-
temporaryPath = tryToOpenTemporaryFile(OS, outputPath, openFlags);
135+
temporaryPath = tryToOpenTemporaryFile(OS, outputPath);
141136

142137
if (!temporaryPath) {
143138
assert(!OS.hasValue());
@@ -149,7 +144,7 @@ std::error_code swift::atomicallyWritingToFile(
149144

150145
if (!OS.hasValue()) {
151146
std::error_code error;
152-
OS.emplace(outputPath, error, openFlags);
147+
OS.emplace(outputPath, error, fs::F_None);
153148
if (error)
154149
return error;
155150
}

Diff for: lib/FrontendTool/FrontendTool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static bool atomicallyWritingToTextFile(
322322

323323
bool actionFailed = false;
324324
std::error_code EC =
325-
swift::atomicallyWritingToFile(outputPath, /*binary*/false,
325+
swift::atomicallyWritingToFile(outputPath,
326326
[&](llvm::raw_pwrite_stream &out) {
327327
actionFailed = action(out);
328328
});

Diff for: lib/Serialization/Serialization.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -5084,7 +5084,6 @@ static inline bool
50845084
withOutputFile(ASTContext &ctx, StringRef outputPath,
50855085
llvm::function_ref<void(raw_ostream &)> action){
50865086
std::error_code EC = swift::atomicallyWritingToFile(outputPath,
5087-
/*binary*/true,
50885087
action);
50895088
if (!EC)
50905089
return false;

0 commit comments

Comments
 (0)