aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/FileSystemStatCache.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 19:56:39 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 19:56:39 +0000
commit11aa4b03b054cb9d3c201bba5632241145865e29 (patch)
treee2870984eacece20d7cfe36bf8556127737e51a3 /include/clang/Basic/FileSystemStatCache.h
parentf8f6129861f3972dab2c5a6cde29711ac780a7d0 (diff)
factor the "cache miss" handling code out of FM into a static
method in FileSystemStatCache. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120037 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileSystemStatCache.h')
-rw-r--r--include/clang/Basic/FileSystemStatCache.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h
index bcfa52dd86..7bb3706793 100644
--- a/include/clang/Basic/FileSystemStatCache.h
+++ b/include/clang/Basic/FileSystemStatCache.h
@@ -36,8 +36,21 @@ public:
CacheHitMissing, //< We know that the file doesn't exist.
CacheMiss //< We don't know anything about the file.
};
-
- virtual LookupResult getStat(const char *Path, struct stat &StatBuf) = 0;
+
+ /// FileSystemStatCache::get - Get the 'stat' information for the specified
+ /// path, using the cache to accellerate it if possible. This returns true if
+ /// 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);
+
+ if (R == FileSystemStatCache::CacheMiss)
+ return ::stat(Path, &StatBuf);
+ return R == FileSystemStatCache::CacheHitMissing;
+ }
/// \brief Sets the next stat call cache in the chain of stat caches.
/// Takes ownership of the given stat cache.
@@ -54,6 +67,8 @@ public:
FileSystemStatCache *takeNextStatCache() { return NextStatCache.take(); }
protected:
+ virtual LookupResult getStat(const char *Path, struct stat &StatBuf) = 0;
+
LookupResult statChained(const char *Path, struct stat &StatBuf) {
if (FileSystemStatCache *Next = getNextStatCache())
return Next->getStat(Path, StatBuf);