Skip to content

Commit 64c4ae6

Browse files
authored
Merge pull request #18472 from gottesmm/pr-e32569f4f04c02ff378bcf2514fc38fcff9253b9
2 parents c1029b6 + 7e70389 commit 64c4ae6

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

include/swift/Basic/FileSystem.h

Lines changed: 1 addition & 1 deletion
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

lib/Basic/FileSystem.cpp

Lines changed: 5 additions & 10 deletions
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
}

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 1 deletion
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
});

lib/Serialization/Serialization.cpp

Lines changed: 0 additions & 1 deletion
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)