[cfe-commits] r120038 - in /cfe/trunk: include/clang/Basic/FileSystemStatCache.h lib/Basic/FileSystemStatCache.cpp lib/Frontend/CacheTokens.cpp lib/Lex/PTHLexer.cpp lib/Serialization/ASTReader.cpp
Chris Lattner
sabre at nondot.org
Tue Nov 23 12:05:15 PST 2010
Author: lattner
Date: Tue Nov 23 14:05:15 2010
New Revision: 120038
URL: http://llvm.org/viewvc/llvm-project?rev=120038&view=rev
Log:
simplify the cache miss handling code, eliminating CacheMissing.
Modified:
cfe/trunk/include/clang/Basic/FileSystemStatCache.h
cfe/trunk/lib/Basic/FileSystemStatCache.cpp
cfe/trunk/lib/Frontend/CacheTokens.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileSystemStatCache.h?rev=120038&r1=120037&r2=120038&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original)
+++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Nov 23 14:05:15 2010
@@ -32,9 +32,8 @@
virtual ~FileSystemStatCache() {}
enum LookupResult {
- CacheHitExists, //< We know the file exists and its cached stat data.
- CacheHitMissing, //< We know that the file doesn't exist.
- CacheMiss //< We don't know anything about the file.
+ CacheExists, //< We know the file exists and its cached stat data.
+ CacheMissing //< We know that the file doesn't exist.
};
/// FileSystemStatCache::get - Get the 'stat' information for the specified
@@ -42,14 +41,10 @@
/// the path does not exist or false if it exists.
static bool get(const char *Path, struct stat &StatBuf,
FileSystemStatCache *Cache) {
- LookupResult R = CacheMiss;
-
if (Cache)
- R = Cache->getStat(Path, StatBuf);
+ return Cache->getStat(Path, StatBuf) == CacheMissing;
- if (R == FileSystemStatCache::CacheMiss)
- return ::stat(Path, &StatBuf);
- return R == FileSystemStatCache::CacheHitMissing;
+ return ::stat(Path, &StatBuf) != 0;
}
/// \brief Sets the next stat call cache in the chain of stat caches.
@@ -73,7 +68,9 @@
if (FileSystemStatCache *Next = getNextStatCache())
return Next->getStat(Path, StatBuf);
- return CacheMiss;
+ // If we hit the end of the list of stat caches to try, just compute and
+ // return it without a cache.
+ return get(Path, StatBuf, 0) ? CacheMissing : CacheExists;
}
};
Modified: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=120038&r1=120037&r2=120038&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp (original)
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp Tue Nov 23 14:05:15 2010
@@ -19,16 +19,11 @@
MemorizeStatCalls::getStat(const char *Path, struct stat &StatBuf) {
LookupResult Result = statChained(Path, StatBuf);
- // If the chained cache didn't know anything about the file, do the stat now
- // so we can record the result.
- if (Result == CacheMiss)
- Result = ::stat(Path, &StatBuf) ? CacheHitMissing : CacheHitExists;
-
// Do not cache failed stats, it is easy to construct common inconsistent
// situations if we do, and they are not important for PCH performance (which
// currently only needs the stats to construct the initial FileManager
// entries).
- if (Result == CacheHitMissing)
+ if (Result == CacheMissing)
return Result;
// Cache file 'stat' results and directories with absolutely paths.
Modified: cfe/trunk/lib/Frontend/CacheTokens.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CacheTokens.cpp?rev=120038&r1=120037&r2=120038&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CacheTokens.cpp (original)
+++ cfe/trunk/lib/Frontend/CacheTokens.cpp Tue Nov 23 14:05:15 2010
@@ -518,14 +518,9 @@
~StatListener() {}
LookupResult getStat(const char *Path, struct stat &StatBuf) {
- LookupResult Result = FileSystemStatCache::statChained(Path, StatBuf);
+ LookupResult Result = statChained(Path, StatBuf);
- // If the chained cache didn't know anything about the file, do the stat now
- // so we can record the result.
- if (Result == CacheMiss)
- Result = ::stat(Path, &StatBuf) ? CacheHitMissing : CacheHitExists;
-
- if (Result == CacheHitMissing) // Failed 'stat'.
+ if (Result == CacheMissing) // Failed 'stat'.
PM.insert(PTHEntryKeyVariant(Path), PTHEntry());
else if (S_ISDIR(StatBuf.st_mode)) {
// Only cache directories with absolute paths.
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=120038&r1=120037&r2=120038&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Tue Nov 23 14:05:15 2010
@@ -26,7 +26,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/MemoryBuffer.h"
-#include <sys/stat.h>
using namespace clang;
using namespace clang::io;
@@ -690,14 +689,14 @@
const PTHStatData &Data = *I;
if (!Data.hasStat)
- return CacheHitMissing;
+ return CacheMissing;
StatBuf.st_ino = Data.ino;
StatBuf.st_dev = Data.dev;
StatBuf.st_mtime = Data.mtime;
StatBuf.st_mode = Data.mode;
StatBuf.st_size = Data.size;
- return CacheHitExists;
+ return CacheExists;
}
};
} // end anonymous namespace
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=120038&r1=120037&r2=120038&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Nov 23 14:05:15 2010
@@ -1092,7 +1092,7 @@
StatBuf.st_mtime = Data.mtime;
StatBuf.st_mode = Data.mode;
StatBuf.st_size = Data.size;
- return CacheHitExists;
+ return CacheExists;
}
};
} // end anonymous namespace
More information about the cfe-commits
mailing list