[llvm] r310137 - [Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 14:52:00 PDT 2017


Author: rnk
Date: Fri Aug  4 14:52:00 2017
New Revision: 310137

URL: http://llvm.org/viewvc/llvm-project?rev=310137&view=rev
Log:
[Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows

Summary:
Tools like clang that use RemoveFileOnSignal on their output files
weren't actually able to clean up their outputs before this change.  Now
the call to llvm::sys::fs::remove succeeds and the temporary file is
deleted. This is a stop-gap to fix clang before implementing the
solution outlined in PR34070.

Reviewers: davide

Subscribers: llvm-commits, hiraditya

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

Modified:
    llvm/trunk/lib/Support/Windows/Path.inc

Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=310137&r1=310136&r2=310137&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Fri Aug  4 14:52:00 2017
@@ -925,9 +925,10 @@ std::error_code openFileForWrite(const T
   if (Flags & F_RW)
     Access |= GENERIC_READ;
 
-  HANDLE H = ::CreateFileW(PathUTF16.begin(), Access,
-                           FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
-                           CreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
+  HANDLE H =
+      ::CreateFileW(PathUTF16.begin(), Access,
+                    FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+                    NULL, CreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
 
   if (H == INVALID_HANDLE_VALUE) {
     DWORD LastError = ::GetLastError();




More information about the llvm-commits mailing list