diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-23 19:19:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-23 19:19:34 +0000 |
commit | 226efd356c6c98a4de2880e6090aa2f05b459fc5 (patch) | |
tree | 10f7d47ea7136c139ac252d3b9f7e0215c766b61 /clang/lib/Frontend | |
parent | e5cb2787667ffd67f831dac78abe8c3acd046f9e (diff) | |
download | bcm5719-llvm-226efd356c6c98a4de2880e6090aa2f05b459fc5.tar.gz bcm5719-llvm-226efd356c6c98a4de2880e6090aa2f05b459fc5.zip |
rework the stat cache, pulling it out of FileManager.h into
its own header and giving it some more structure. No
functionality change.
llvm-svn: 120030
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/CacheTokens.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp index 2defce340f8..94bee6b868b 100644 --- a/clang/lib/Frontend/CacheTokens.cpp +++ b/clang/lib/Frontend/CacheTokens.cpp @@ -13,11 +13,12 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/Utils.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileManager.h" -#include "clang/Basic/SourceManager.h" +#include "clang/Basic/FileSystemStatCache.h" #include "clang/Basic/IdentifierTable.h" -#include "clang/Basic/Diagnostic.h" #include "clang/Basic/OnDiskHashTable.h" +#include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringExtras.h" @@ -510,26 +511,31 @@ namespace { /// as input to PTH generation. StatListener populates the PTHWriter's /// file map with stat information for directories as well as negative stats. /// Stat information for files are populated elsewhere. -class StatListener : public StatSysCallCache { +class StatListener : public FileSystemStatCache { PTHMap &PM; public: StatListener(PTHMap &pm) : PM(pm) {} ~StatListener() {} - int stat(const char *path, struct stat *buf) { - int result = StatSysCallCache::stat(path, buf); - - if (result != 0) // Failed 'stat'. - PM.insert(PTHEntryKeyVariant(path), PTHEntry()); - else if (S_ISDIR(buf->st_mode)) { + LookupResult getStat(const char *Path, struct stat &StatBuf) { + LookupResult Result = FileSystemStatCache::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'. + PM.insert(PTHEntryKeyVariant(Path), PTHEntry()); + else if (S_ISDIR(StatBuf.st_mode)) { // Only cache directories with absolute paths. - if (!llvm::sys::Path(path).isAbsolute()) - return result; + if (!llvm::sys::Path(Path).isAbsolute()) + return Result; - PM.insert(PTHEntryKeyVariant(buf, path), PTHEntry()); + PM.insert(PTHEntryKeyVariant(&StatBuf, Path), PTHEntry()); } - return result; + return Result; } }; } // end anonymous namespace |