]> granicus.if.org Git - clang/commitdiff
Improve r159256 following Chandler's comments:
authorAxel Naumann <Axel.Naumann@cern.ch>
Tue, 10 Jul 2012 16:50:27 +0000 (16:50 +0000)
committerAxel Naumann <Axel.Naumann@cern.ch>
Tue, 10 Jul 2012 16:50:27 +0000 (16:50 +0000)
Implement UniqueFileContainer::erase(), camelCase, add comment on future optimizations of the cache versus de-optimizations of invalidations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159997 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/FileManager.h
lib/Basic/FileManager.cpp

index deb9caf4661ef3f967def176fa64cb39c5f617a9..ea58e2d76a72d8b3a04a164002a6036083ce897a 100644 (file)
@@ -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
index 100f3ceaf044fd933a0e32be4c663051bc88f08f..9804105e67166f8b666b748c0e43ca086b089d4e 100644 (file)
@@ -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);
 }