diff options
author | Amy Huang <akhuang@google.com> | 2021-05-04 11:28:28 -0700 |
---|---|---|
committer | Amy Huang <akhuang@google.com> | 2021-06-01 17:09:08 -0700 |
commit | 7daa18215905c831e130c7542f17619e9d936dfc (patch) | |
tree | d239ce8493cf81c6d2c4773800d21a21708eaff1 /llvm/lib/Support/Path.cpp | |
parent | 9e2e49328f19eeeab63c08721122815a27b2dad5 (diff) | |
download | llvm-7daa18215905c831e130c7542f17619e9d936dfc.zip llvm-7daa18215905c831e130c7542f17619e9d936dfc.tar.gz llvm-7daa18215905c831e130c7542f17619e9d936dfc.tar.bz2 |
Fix tmp files being left on Windows builds.
Clang writes object files by first writing to a .tmp file and then
renaming to the final .obj name. On Windows, if a compile is killed
partway through the .tmp files don't get deleted.
Currently it seems like RemoveFileOnSignal takes care of deleting the
tmp files on Linux, but on Windows we need to call
setDeleteDisposition on tmp files so that they are deleted when
closed.
This patch switches to using TempFile to create the .tmp files we write
when creating object files, since it uses setDeleteDisposition on Windows.
This change applies to both Linux and Windows for consistency.
Differential Revision: https://reviews.llvm.org/D102876
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 005c27c3..d549b00 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1229,7 +1229,7 @@ Error TempFile::keep(const Twine &Name) { auto H = reinterpret_cast<HANDLE>(_get_osfhandle(FD)); std::error_code RenameEC = setDeleteDisposition(H, false); if (!RenameEC) { - RenameEC = rename_fd(FD, Name); + RenameEC = rename_handle(H, Name); // If rename failed because it's cross-device, copy instead if (RenameEC == std::error_code(ERROR_NOT_SAME_DEVICE, std::system_category())) { |