diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-12 00:39:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-12 00:39:05 +0000 |
commit | c8b740eade3a96dd7ad1bada99bce5d411fa25b9 (patch) | |
tree | f20e57e3c538a7cb99878c54197b54a1f813af2b /clang/lib/Basic/FileManager.cpp | |
parent | 6752502b81367869062655406908d30653813f2a (diff) | |
download | bcm5719-llvm-c8b740eade3a96dd7ad1bada99bce5d411fa25b9.tar.gz bcm5719-llvm-c8b740eade3a96dd7ad1bada99bce5d411fa25b9.zip |
Add lightweight shim "clang::StatSysCallCache" that caches 'stat' system calls
for use by FileManager. FileManager now takes a StatSysCallCache* in its
constructor (which defaults to NULL). This will be used for evaluating whether
or not caching 'stat' system calls in PTH is a performance win. This shim adds
no observable performance impact in the case where the 'StatSysCallCache*' is
null.
llvm-svn: 64345
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 9ae1ad4c28d..666c984e239 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -29,7 +29,7 @@ using namespace clang; #include <sys/stat.h> #if defined(_MSC_VER) -#define S_ISDIR(s) (_S_IFDIR & s) +#defisstne S_ISDIR(s) (_S_IFDIR & s) #endif /// NON_EXISTENT_DIR - A special value distinct from null that is used to @@ -134,10 +134,11 @@ public: // Common logic. //===----------------------------------------------------------------------===// -FileManager::FileManager() : UniqueDirs(*new UniqueDirContainer), - UniqueFiles(*new UniqueFileContainer), - DirEntries(64), FileEntries(64), NextFileUID(0) -{ +FileManager::FileManager(StatSysCallCache* statCache) + : UniqueDirs(*new UniqueDirContainer), + UniqueFiles(*new UniqueFileContainer), + DirEntries(64), FileEntries(64), NextFileUID(0), + StatCache(statCache) { NumDirLookups = NumFileLookups = 0; NumDirCacheMisses = NumFileCacheMisses = 0; } @@ -145,6 +146,7 @@ FileManager::FileManager() : UniqueDirs(*new UniqueDirContainer), FileManager::~FileManager() { delete &UniqueDirs; delete &UniqueFiles; + delete StatCache; } @@ -173,7 +175,7 @@ const DirectoryEntry *FileManager::getDirectory(const char *NameStart, // Check to see if the directory exists. struct stat StatBuf; - if (stat(InterndDirName, &StatBuf) || // Error stat'ing. + if (stat_cached(InterndDirName, &StatBuf) || // Error stat'ing. !S_ISDIR(StatBuf.st_mode)) // Not a directory? return 0; @@ -246,8 +248,8 @@ const FileEntry *FileManager::getFile(const char *NameStart, // Nope, there isn't. Check to see if the file exists. struct stat StatBuf; //llvm::cerr << "STATING: " << Filename; - if (stat(InterndFileName, &StatBuf) || // Error stat'ing. - S_ISDIR(StatBuf.st_mode)) { // A directory? + if (stat_cached(InterndFileName, &StatBuf) || // Error stat'ing. + S_ISDIR(StatBuf.st_mode)) { // A directory? // If this file doesn't exist, we leave a null in FileEntries for this path. //llvm::cerr << ": Not existing\n"; return 0; |