[cfe-commits] r159997 - in /cfe/trunk: include/clang/Basic/FileManager.h lib/Basic/FileManager.cpp

Axel Naumann Axel.Naumann at cern.ch
Tue Jul 10 09:50:27 PDT 2012


Author: axel
Date: Tue Jul 10 11:50:27 2012
New Revision: 159997

URL: http://llvm.org/viewvc/llvm-project?rev=159997&view=rev
Log:
Improve r159256 following Chandler's comments:
Implement UniqueFileContainer::erase(), camelCase, add comment on future optimizations of the cache versus de-optimizations of invalidations.

Modified:
    cfe/trunk/include/clang/Basic/FileManager.h
    cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=159997&r1=159996&r2=159997&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Tue Jul 10 11:50:27 2012
@@ -232,7 +232,7 @@
   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

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=159997&r1=159996&r2=159997&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Jul 10 11:50:27 2012
@@ -112,7 +112,7 @@
 
   size_t size() const { return UniqueFiles.size(); }
 
-  friend class FileManager;
+  void erase(const FileEntry *Entry) { UniqueFiles.erase(Entry->getName()); }
 };
 
 //===----------------------------------------------------------------------===//
@@ -155,7 +155,7 @@
 
   size_t size() const { return UniqueFiles.size(); }
 
-  friend class FileManager;
+  void erase(const FileEntry *Entry) { UniqueFiles.erase(*Entry); }
 };
 
 #endif
@@ -563,16 +563,15 @@
   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);
 }
 
 





More information about the cfe-commits mailing list