]> granicus.if.org Git - clang/commitdiff
From Vassil Vassilev:
authorAxel Naumann <Axel.Naumann@cern.ch>
Wed, 27 Jun 2012 09:17:42 +0000 (09:17 +0000)
committerAxel Naumann <Axel.Naumann@cern.ch>
Wed, 27 Jun 2012 09:17:42 +0000 (09:17 +0000)
add interface for removing a FileEntry from the cache.
Forces a re-read the contents from disk, e.g. because a tool (like cling) wants to pick up a modified file.

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

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

index 909213d748f251ef822a0ad3c6d72aa111e67b7e..b14ad83df25ce73d1ef6d417a1d834e9fa6ee6cb 100644 (file)
@@ -222,6 +222,9 @@ public:
   /// FileManager's FileSystemOptions.
   bool getNoncachedStatValue(StringRef Path, struct stat &StatBuf);
 
+  /// \brief Remove the real file Entry from the cache.
+  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
   /// working directory.
index 75333f8fb55bda55c6e775afed7eabacbcc484c0..16906de55abf385ebfc1f6c6f2b258b2bc901786 100644 (file)
@@ -111,6 +111,8 @@ public:
   }
 
   size_t size() const { return UniqueFiles.size(); }
+
+  friend class FileManager;
 };
 
 //===----------------------------------------------------------------------===//
@@ -152,6 +154,8 @@ public:
   }
 
   size_t size() const { return UniqueFiles.size(); }
+
+  friend class FileManager;
 };
 
 #endif
@@ -559,6 +563,15 @@ bool FileManager::getNoncachedStatValue(StringRef Path,
   return ::stat(FilePath.c_str(), &StatBuf) != 0;
 }
 
+void FileManager::InvalidateCache(const FileEntry* Entry) {
+  if (!Entry)
+    return;
+
+  SeenFileEntries.erase(Entry->getName());
+  UniqueRealFiles.UniqueFiles.erase(*Entry);
+}
+
+
 void FileManager::GetUniqueIDMapping(
                    SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
   UIDToFiles.clear();