Remove stat cache chaining as it's no longer needed after PTH support has been
removed
Stat cache chaining was implemented for a StatListener in the PTH writer so that
it could write out the stat information to PTH. r348266 removed support for PTH,
and it doesn't seem like there are other uses of stat cache chaining. We can
remove the chaining support.
Differential Revision: https://reviews.llvm.org/D55455
llvm-svn: 349942
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 455d25c..f5a2d48 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -63,44 +63,12 @@
FileManager::~FileManager() = default;
-void FileManager::addStatCache(std::unique_ptr<FileSystemStatCache> statCache,
- bool AtBeginning) {
+void FileManager::setStatCache(std::unique_ptr<FileSystemStatCache> statCache) {
assert(statCache && "No stat cache provided?");
- if (AtBeginning || !StatCache.get()) {
- statCache->setNextStatCache(std::move(StatCache));
- StatCache = std::move(statCache);
- return;
- }
-
- FileSystemStatCache *LastCache = StatCache.get();
- while (LastCache->getNextStatCache())
- LastCache = LastCache->getNextStatCache();
-
- LastCache->setNextStatCache(std::move(statCache));
+ StatCache = std::move(statCache);
}
-void FileManager::removeStatCache(FileSystemStatCache *statCache) {
- if (!statCache)
- return;
-
- if (StatCache.get() == statCache) {
- // This is the first stat cache.
- StatCache = StatCache->takeNextStatCache();
- return;
- }
-
- // Find the stat cache in the list.
- FileSystemStatCache *PrevCache = StatCache.get();
- while (PrevCache && PrevCache->getNextStatCache() != statCache)
- PrevCache = PrevCache->getNextStatCache();
-
- assert(PrevCache && "Stat cache not found for removal");
- PrevCache->setNextStatCache(statCache->takeNextStatCache());
-}
-
-void FileManager::clearStatCaches() {
- StatCache.reset();
-}
+void FileManager::clearStatCache() { StatCache.reset(); }
/// Retrieve the directory that the given file name resides in.
/// Filename can point to either a real file or a virtual file.
diff --git a/clang/lib/Basic/FileSystemStatCache.cpp b/clang/lib/Basic/FileSystemStatCache.cpp
index 9a515e8..6f2eef4 100644
--- a/clang/lib/Basic/FileSystemStatCache.cpp
+++ b/clang/lib/Basic/FileSystemStatCache.cpp
@@ -114,18 +114,17 @@
MemorizeStatCalls::getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) {
- LookupResult Result = statChained(Path, Data, isFile, F, FS);
-
- // 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 == CacheMissing)
- return Result;
+ if (get(Path, Data, isFile, F, nullptr, FS)) {
+ // 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).
+ return CacheMissing;
+ }
// Cache file 'stat' results and directories with absolutely paths.
if (!Data.IsDirectory || llvm::sys::path::is_absolute(Path))
StatCalls[Path] = Data;
- return Result;
+ return CacheExists;
}