diff options
Diffstat (limited to 'lib/Basic/FileManager.cpp')
-rw-r--r-- | lib/Basic/FileManager.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 2cd140d95e..cc25d33051 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -19,6 +19,7 @@ #include "clang/Basic/FileManager.h" #include "llvm/ADT/SmallString.h" +#include "llvm/System/Path.h" #include "llvm/Support/Streams.h" #include "llvm/Config/config.h" using namespace clang; @@ -282,3 +283,20 @@ void FileManager::PrintStats() const { //llvm::cerr << PagesMapped << BytesOfPagesMapped << FSLookups; } + +int MemorizeStatCalls::stat(const char *path, struct stat *buf) { + int result = ::stat(path, buf); + + if (result != 0) { + // Cache failed 'stat' results. + struct stat empty; + StatCalls[path] = StatResult(result, empty); + } + else if (!S_ISDIR(buf->st_mode) || llvm::sys::Path(path).isAbsolute()) { + // Cache file 'stat' results and directories with absolutely + // paths. + StatCalls[path] = StatResult(result, *buf); + } + + return result; +} |