[lld] r317663 - Remove a given file even if openFileForRead fails.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 20:22:40 PST 2017
Author: ruiu
Date: Tue Nov 7 20:22:40 2017
New Revision: 317663
URL: http://llvm.org/viewvc/llvm-project?rev=317663&view=rev
Log:
Remove a given file even if openFileForRead fails.
I think the constract of this function is to remove a file in some way,
whether in background or in foreground. This patch makes sure that it
removes a given file.
Differential Revision: https://reviews.llvm.org/D39778
Modified:
lld/trunk/ELF/Filesystem.cpp
Modified: lld/trunk/ELF/Filesystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Filesystem.cpp?rev=317663&r1=317662&r2=317663&view=diff
==============================================================================
--- lld/trunk/ELF/Filesystem.cpp (original)
+++ lld/trunk/ELF/Filesystem.cpp Tue Nov 7 20:22:40 2017
@@ -56,13 +56,12 @@ void elf::unlinkAsync(StringRef Path) {
// Instead we open the file and unlink it on this thread. The unlink is fast
// since the open fd guarantees that it is not removing the last reference.
int FD;
- if (sys::fs::openFileForRead(Path, FD))
- return;
-
+ std::error_code EC = sys::fs::openFileForRead(Path, FD);
sys::fs::remove(Path);
// close and therefore remove TempPath in background.
- std::thread([=] { ::close(FD); }).detach();
+ if (!EC)
+ std::thread([=] { ::close(FD); }).detach();
#endif
}
More information about the llvm-commits
mailing list