aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/FileManager.h2
-rw-r--r--lib/Basic/FileManager.cpp19
2 files changed, 10 insertions, 11 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index deb9caf466..ea58e2d76a 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -232,7 +232,7 @@ public:
bool getNoncachedStatValue(StringRef Path, struct stat &StatBuf);
/// \brief Remove the real file \p Entry from the cache.
- void InvalidateCache(const FileEntry* Entry);
+ void invalidateCache(const FileEntry *Entry);
/// \brief If path is not absolute and FileSystemOptions set the working
/// directory, the path is modified to be relative to the given
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index 100f3ceaf0..9804105e67 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -112,7 +112,7 @@ public:
size_t size() const { return UniqueFiles.size(); }
- friend class FileManager;
+ void erase(const FileEntry *Entry) { UniqueFiles.erase(Entry->getName()); }
};
//===----------------------------------------------------------------------===//
@@ -155,7 +155,7 @@ public:
size_t size() const { return UniqueFiles.size(); }
- friend class FileManager;
+ void erase(const FileEntry *Entry) { UniqueFiles.erase(*Entry); }
};
#endif
@@ -563,16 +563,15 @@ bool FileManager::getNoncachedStatValue(StringRef Path,
return ::stat(FilePath.c_str(), &StatBuf) != 0;
}
-void FileManager::InvalidateCache(const FileEntry* Entry) {
- if (!Entry)
- return;
+void FileManager::invalidateCache(const FileEntry *Entry) {
+ assert(Entry && "Cannot invalidate a NULL FileEntry");
SeenFileEntries.erase(Entry->getName());
-#ifdef LLVM_ON_WIN32
- UniqueRealFiles.UniqueFiles.erase(Entry->getName());
-#else
- UniqueRealFiles.UniqueFiles.erase(*Entry);
-#endif
+
+ // FileEntry invalidation should not block future optimizations in the file
+ // caches. Possible alternatives are cache truncation (invalidate last N) or
+ // invalidation of the whole cache.
+ UniqueRealFiles.erase(Entry);
}