Sfoglia il codice sorgente

From Vassil Vassilev:
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

Axel Naumann 13 anni fa
parent
commit
3ce42c37b0
2 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 3 0
      include/clang/Basic/FileManager.h
  2. 13 0
      lib/Basic/FileManager.cpp

+ 3 - 0
include/clang/Basic/FileManager.h

@@ -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.

+ 13 - 0
lib/Basic/FileManager.cpp

@@ -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();