From c06376acbaf8eb557ec4b5b49318cd2635e0c38a Mon Sep 17 00:00:00 2001 From: Amy Huang Date: Tue, 1 Jun 2021 19:51:47 -0700 Subject: [PATCH] Revert "Fix tmp files being left on Windows builds." for now; causing some asan test failures. This reverts commit 7daa18215905c831e130c7542f17619e9d936dfc. --- lib/Support/Path.cpp | 2 +- lib/Support/Windows/Path.inc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index d549b0011b1..005c27c3a42 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -1229,7 +1229,7 @@ Error TempFile::keep(const Twine &Name) { auto H = reinterpret_cast(_get_osfhandle(FD)); std::error_code RenameEC = setDeleteDisposition(H, false); if (!RenameEC) { - RenameEC = rename_handle(H, Name); + 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())) { diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index daa69bf04b4..19b9f9ef7cb 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -560,6 +560,11 @@ static std::error_code rename_handle(HANDLE FromHandle, const Twine &To) { return errc::permission_denied; } +static std::error_code rename_fd(int FromFD, const Twine &To) { + HANDLE FromHandle = reinterpret_cast(_get_osfhandle(FromFD)); + return rename_handle(FromHandle, To); +} + std::error_code rename(const Twine &From, const Twine &To) { // Convert to utf-16. SmallVector WideFrom;