diff options
author | Dan Gohman <gohman@apple.com> | 2010-10-29 23:26:14 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-10-29 23:26:14 +0000 |
commit | 978e3a274aae203a6c2b74094be791ac9e2662e5 (patch) | |
tree | 83b3740323283f63b4d50ce4b99fd05034e3db4f /lib/Driver/Compilation.cpp | |
parent | 1e592cba6bc1930e7a01dde8370e5345cef05723 (diff) |
Don't test isRegularFile before calling eraseFromDisk, since
eraseFromDisk does the same check. This avoids a stat call
in the common case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Compilation.cpp')
-rw-r--r-- | lib/Driver/Compilation.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index c059afd454..066e88ebe1 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -101,21 +101,15 @@ bool Compilation::CleanupFileList(const ArgStringList &Files, llvm::sys::Path P(*it); std::string Error; - if (!P.isRegularFile()) { - // If we have a special file in our list, i.e. /dev/null - // then don't call eraseFromDisk() and just continue. - continue; - } - if (P.eraseFromDisk(false, &Error)) { - // Failure is only failure if the file doesn't exist. There is a - // race condition here due to the limited interface of - // llvm::sys::Path, we want to know if the removal gave E_NOENT. + // Failure is only failure if the file exists and is "regular". There is + // a race condition here due to the limited interface of + // llvm::sys::Path, we want to know if the removal gave ENOENT. // FIXME: Grumble, P.exists() is broken. PR3837. struct stat buf; - if (::stat(P.c_str(), &buf) == 0 - || errno != ENOENT) { + if (::stat(P.c_str(), &buf) == 0 ? S_ISREG(buf.st_mode) : + (errno != ENOENT)) { if (IssueErrors) getDriver().Diag(clang::diag::err_drv_unable_to_remove_file) << Error; |