[llvm-branch-commits] [llvm-branch] r340030 - Merging r338841:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 17 07:28:34 PDT 2018


Author: hans
Date: Fri Aug 17 07:28:33 2018
New Revision: 340030

URL: http://llvm.org/viewvc/llvm-project?rev=340030&view=rev
Log:
Merging r338841:
------------------------------------------------------------------------
r338841 | jmorse | 2018-08-03 12:13:35 +0200 (Fri, 03 Aug 2018) | 11 lines

[Windows FS] Allow moving files in TempFile::keep

In r338216 / D49860 TempFile::keep was extended to allow keeping across
filesystems. The aim on Windows was to have this happen in rename_internal
using the existing system API. However, to fix an issue and preserve the
idea of "renaming" not being a move, put Windows keep-across-filesystem in
TempFile::keep.

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


------------------------------------------------------------------------

Modified:
    llvm/branches/release_70/   (props changed)
    llvm/branches/release_70/lib/Support/Path.cpp
    llvm/branches/release_70/lib/Support/Windows/Path.inc

Propchange: llvm/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 17 07:28:33 2018
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,338552,338554,338569,338599,338610,338658,338665,338682,338703,338709,338716,338751,338762,338817,338902,338915,338968,339073,339166,339179,339184,339190,339225,339316,339319,339411,339492,339515,339533,339535-339536,339600,339636,339769,339883,339945
+/llvm/trunk:155241,338552,338554,338569,338599,338610,338658,338665,338682,338703,338709,338716,338751,338762,338817,338841,338902,338915,338968,339073,339166,339179,339184,339190,339225,339316,339319,339411,339492,339515,339533,339535-339536,339600,339636,339769,339883,339945

Modified: llvm/branches/release_70/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/lib/Support/Path.cpp?rev=340030&r1=340029&r2=340030&view=diff
==============================================================================
--- llvm/branches/release_70/lib/Support/Path.cpp (original)
+++ llvm/branches/release_70/lib/Support/Path.cpp Fri Aug 17 07:28:33 2018
@@ -1150,8 +1150,16 @@ Error TempFile::keep(const Twine &Name)
   // If we can't cancel the delete don't rename.
   auto H = reinterpret_cast<HANDLE>(_get_osfhandle(FD));
   std::error_code RenameEC = setDeleteDisposition(H, false);
-  if (!RenameEC)
+  if (!RenameEC) {
     RenameEC = rename_fd(FD, Name);
+    // If rename failed because it's cross-device, copy instead
+    if (RenameEC ==
+      std::error_code(ERROR_NOT_SAME_DEVICE, std::system_category())) {
+      RenameEC = copy_file(TmpName, Name);
+      setDeleteDisposition(H, true);
+    }
+  }
+
   // If we can't rename, discard the temporary file.
   if (RenameEC)
     setDeleteDisposition(H, true);

Modified: llvm/branches/release_70/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/lib/Support/Windows/Path.inc?rev=340030&r1=340029&r2=340030&view=diff
==============================================================================
--- llvm/branches/release_70/lib/Support/Windows/Path.inc (original)
+++ llvm/branches/release_70/lib/Support/Windows/Path.inc Fri Aug 17 07:28:33 2018
@@ -450,7 +450,7 @@ static std::error_code rename_handle(HAN
       if (std::error_code EC2 = realPathFromHandle(FromHandle, WideFrom))
         return EC2;
       if (::MoveFileExW(WideFrom.begin(), WideTo.begin(),
-                        MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
+                        MOVEFILE_REPLACE_EXISTING))
         return std::error_code();
       return mapWindowsError(GetLastError());
     }




More information about the llvm-branch-commits mailing list