Skip to content

Commit

Permalink
Revert "Remove FileManager::invalidateCache as it has no callers an…
Browse files Browse the repository at this point in the history
…ymore. NFC."

This reverts commit 0785f8d.
  • Loading branch information
sbingner committed Jan 7, 2020
1 parent 5d60b79 commit 043a234
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ class FileManager : public RefCountedBase<FileManager> {
std::error_code getNoncachedStatValue(StringRef Path,
llvm::vfs::Status &Result);

/// Remove the real file \p Entry from the cache.
void invalidateCache(const FileEntry *Entry);

/// If path is not absolute and FileSystemOptions set the working
/// directory, the path is modified to be relative to the given
/// working directory.
Expand Down
14 changes: 14 additions & 0 deletions clang/lib/Basic/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,20 @@ FileManager::getNoncachedStatValue(StringRef Path,
return std::error_code();
}

void FileManager::invalidateCache(const FileEntry *Entry) {
assert(Entry && "Cannot invalidate a NULL FileEntry");

SeenFileEntries.erase(Entry->getName());

// 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.
//
// FIXME: This is broken. We sometimes have the same FileEntry* shared
// between multiple SeenFileEntries, so this can leave dangling pointers.
UniqueRealFiles.erase(Entry->getUniqueID());
}

void FileManager::GetUniqueIDMapping(
SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
UIDToFiles.clear();
Expand Down

0 comments on commit 043a234

Please sign in to comment.