From: Reid Kleckner Date: Fri, 4 Aug 2017 21:52:00 +0000 (+0000) Subject: [Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=033f8efd27b44937696000ecfbaea01f563d5437;p=llvm [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310137 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index 60c03645a57..8dac0e4482b 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -925,9 +925,10 @@ std::error_code openFileForWrite(const Twine &Name, int &ResultFD, 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();