[PATCH] D38283: Do not remove a target file in FileOutputBuffer::create().

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 14:21:16 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL314345: Do not remove a target file in FileOutputBuffer::create(). (authored by ruiu).

Changed prior to commit:
  https://reviews.llvm.org/D38283?vs=116683&id=116883#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38283

Files:
  llvm/trunk/lib/Support/FileOutputBuffer.cpp


Index: llvm/trunk/lib/Support/FileOutputBuffer.cpp
===================================================================
--- llvm/trunk/lib/Support/FileOutputBuffer.cpp
+++ llvm/trunk/lib/Support/FileOutputBuffer.cpp
@@ -65,13 +65,6 @@
       IsRegular = false;
   }
 
-  if (IsRegular) {
-    // Delete target file.
-    EC = sys::fs::remove(FilePath);
-    if (EC)
-      return EC;
-  }
-
   SmallString<128> TempFilePath;
   int FD;
   if (IsRegular) {
@@ -125,7 +118,7 @@
 
   std::error_code EC;
   if (IsRegular) {
-    // Rename file to final name.
+    // Atomically replace the existing file with the new one.
     EC = sys::fs::rename(Twine(TempPath), Twine(FinalPath));
     sys::DontRemoveFileOnSignal(TempPath);
   } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38283.116883.patch
Type: text/x-patch
Size: 736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170927/128327dd/attachment-0001.bin>


More information about the llvm-commits mailing list