[cfe-commits] r117744 - /cfe/trunk/lib/Driver/Compilation.cpp
Dan Gohman
gohman at apple.com
Fri Oct 29 16:26:14 PDT 2010
Author: djg
Date: Fri Oct 29 18:26:14 2010
New Revision: 117744
URL: http://llvm.org/viewvc/llvm-project?rev=117744&view=rev
Log:
Don't test isRegularFile before calling eraseFromDisk, since
eraseFromDisk does the same check. This avoids a stat call
in the common case.
Modified:
cfe/trunk/lib/Driver/Compilation.cpp
Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=117744&r1=117743&r2=117744&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Fri Oct 29 18:26:14 2010
@@ -101,21 +101,15 @@
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;
More information about the cfe-commits
mailing list