aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Basic/FileManager.cpp')
-rw-r--r--lib/Basic/FileManager.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index 9c5f1d59c1..434ff39e77 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -378,17 +378,16 @@ void FileManager::PrintStats() const {
int MemorizeStatCalls::stat(const char *path, struct stat *buf) {
int result = StatSysCallCache::stat(path, buf);
- if (result != 0) {
- // Cache failed 'stat' results.
- struct stat empty;
- memset(&empty, 0, sizeof(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.
+ // Do not cache failed stats, it is easy to construct common inconsistent
+ // situations if we do, and they are not important for PCH performance (which
+ // currently only needs the stats to construct the initial FileManager
+ // entries).
+ if (result != 0)
+ return result;
+
+ // Cache file 'stat' results and directories with absolutely paths.
+ if (!S_ISDIR(buf->st_mode) || llvm::sys::Path(path).isAbsolute())
StatCalls[path] = StatResult(result, *buf);
- }
return result;
}