Skip to content

Commit 501c1fd

Browse files
authored
Replace std::ofstream with llvm::raw_fd_ostream in -verify-apply-fixes (#15133)
This isn't a user-facing feature, but why bother using std::ofstream?
1 parent c1c5931 commit 501c1fd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
#include "swift/Frontend/DiagnosticVerifier.h"
1818
#include "swift/Basic/SourceManager.h"
1919
#include "swift/Parse/Lexer.h"
20+
#include "llvm/Support/FileSystem.h"
2021
#include "llvm/Support/MemoryBuffer.h"
2122
#include "llvm/Support/raw_ostream.h"
22-
#include <fstream>
23+
2324
using namespace swift;
2425

2526
namespace {
@@ -688,9 +689,12 @@ void DiagnosticVerifier::autoApplyFixes(unsigned BufferID,
688689

689690
// Retain the end of the file.
690691
Result.append(LastPos, bufferRange.end());
691-
692-
std::ofstream outs(memBuffer->getBufferIdentifier());
693-
outs << Result;
692+
693+
std::error_code error;
694+
llvm::raw_fd_ostream outs(memBuffer->getBufferIdentifier(), error,
695+
llvm::sys::fs::OpenFlags::F_None);
696+
if (!error)
697+
outs << Result;
694698
}
695699

696700
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)