diff options
author | Shezan Baig <sbaig1@bloomberg.net> | 2022-01-27 13:57:38 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2022-01-27 13:58:25 +0200 |
commit | 659bf6d08c00993b777a96041ffaa98243464598 (patch) | |
tree | b3de45e3c86c36bc37ec5830fb254dd8e76f2eb1 /llvm/lib/Support/Path.cpp | |
parent | b2f50042590577b25184ab0f7d3461d167e6bd9e (diff) | |
download | llvm-659bf6d08c00993b777a96041ffaa98243464598.zip llvm-659bf6d08c00993b777a96041ffaa98243464598.tar.gz llvm-659bf6d08c00993b777a96041ffaa98243464598.tar.bz2 |
[Support] [Windows] Don't cancel delete if we failed to set delete
Following up on commit 177176f75c6fa3f624d6d964b9d340ce39511565, if we
failed to setDeleteDisposition(true) during TempFile creation, then
don't try to setDeleteDisposition(false) during TempFile::keep, since it
will likely fail as well.
Instead of letting TempFile::keep just fail, we should let it go ahead
and try renaming the file.
This fixes an issue we are seeing when running clang-cl.exe through the
Incredibuild distributed build system. We're seeing that renaming
temporary object files would fail here:
https://github.com/llvm/llvm-project/blob/5c1f7b296ac0dddeca02891976e6ab5cfc006719/clang/lib/Frontend/CompilerInstance.cpp#L789
Reviewed By: mstorsjo
Differential Revision: https://reviews.llvm.org/D118212
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 2f80cdb..63d8d4e 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1254,7 +1254,8 @@ Error TempFile::keep(const Twine &Name) { #ifdef _WIN32 // 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); + std::error_code RenameEC = + RemoveOnClose ? std::error_code() : setDeleteDisposition(H, false); bool ShouldDelete = false; if (!RenameEC) { RenameEC = rename_handle(H, Name); |