aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/FileManager.cpp
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 /lib/Basic/FileManager.cpp
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 'lib/Basic/FileManager.cpp')
-rw-r--r--lib/Basic/FileManager.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index b884388c0b..7bb67689bf 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -306,14 +306,12 @@ const FileEntry *FileManager::getFile(llvm::StringRef Filename) {
// Nope, there isn't. Check to see if the file exists.
struct stat StatBuf;
- //llvm::errs() << "STATING: " << Filename;
if (getStatValue(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::errs() << ": Not existing\n";
+ // If this file doesn't exist, we leave NON_EXISTENT_FILE in FileEntries for
+ // this path so subsequent queries get the negative result.
return 0;
}
- //llvm::errs() << ": exists\n";
// It exists. See if we have already opened a file with the same inode.
// This occurs when one dir is symlinked to another, for example.
@@ -416,28 +414,15 @@ getBufferForFile(llvm::StringRef Filename, std::string *ErrorStr) {
/// cache to accellerate it if possible. This returns true if the path does not
/// exist or false if it exists.
bool FileManager::getStatValue(const char *Path, struct stat &StatBuf) {
- FileSystemStatCache::LookupResult Result = FileSystemStatCache::CacheMiss;
-
// FIXME: FileSystemOpts shouldn't be passed in here, all paths should be
// absolute!
- if (FileSystemOpts.WorkingDir.empty()) {
- if (StatCache.get())
- Result = StatCache->getStat(Path, StatBuf);
-
- if (Result == FileSystemStatCache::CacheMiss)
- return ::stat(Path, &StatBuf);
- return Result == FileSystemStatCache::CacheHitMissing;
- }
+ if (FileSystemOpts.WorkingDir.empty())
+ return FileSystemStatCache::get(Path, StatBuf, StatCache.get());
llvm::sys::Path FilePath(Path);
FixupRelativePath(FilePath, FileSystemOpts);
-
- if (StatCache.get())
- Result = StatCache->getStat(FilePath.c_str(), StatBuf);
-
- if (Result == FileSystemStatCache::CacheMiss)
- return ::stat(FilePath.c_str(), &StatBuf);
- return Result == FileSystemStatCache::CacheHitMissing;
+
+ return FileSystemStatCache::get(FilePath.c_str(), StatBuf, StatCache.get());
}