summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Compilation.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-10-29 23:26:14 +0000
committerDan Gohman <gohman@apple.com>2010-10-29 23:26:14 +0000
commite89c04e5187162895d204664d0e9f736b0ce4590 (patch)
tree100a2198aa36909f9a7879a741f549f96170ac59 /clang/lib/Driver/Compilation.cpp
parent182addf159b6156a23106dcd0cba3c5fe204aa62 (diff)
downloadbcm5719-llvm-e89c04e5187162895d204664d0e9f736b0ce4590.tar.gz
bcm5719-llvm-e89c04e5187162895d204664d0e9f736b0ce4590.zip
Don't test isRegularFile before calling eraseFromDisk, since
eraseFromDisk does the same check. This avoids a stat call in the common case. llvm-svn: 117744
Diffstat (limited to 'clang/lib/Driver/Compilation.cpp')
-rw-r--r--clang/lib/Driver/Compilation.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index c059afd4543..066e88ebe12 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud