OSDN Git Service

Delete temp file if rename fails.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 5 Dec 2017 16:40:56 +0000 (16:40 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 5 Dec 2017 16:40:56 +0000 (16:40 +0000)
commit371257ed10a52e22120c7a0dfc204f4e9d25cd93
treebfbe816141abb776856ae3b5e8ab9c54ee3aa551
parentf3c08359d83233e18abce4ed96fb74aecdc3d19e
Delete temp file if rename fails.

Without this when lld failed to replace the output file it would leave
the temporary behind. The problem is that the existing logic is

- cancel the delete flag
- rename

We have to cancel first to avoid renaming and then crashing and
deleting the old version. What is missing then is deleting the
temporary file if the rename fails.

This can be an issue on both unix and windows, but I am not sure how
to cause the rename to fail reliably on unix. I think it can be done
on ZFS since it has an ACL system similar to what windows uses, but
adding support for checking that in llvm-lit is probably not worth it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319786 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/Path.cpp
lib/Support/Windows/Path.inc
test/tools/llvm-objcopy/cannot-delete-dest.test [new file with mode: 0644]