================ @@ -108,6 +108,32 @@ DependencyScanningFilesystemSharedCache::getShardForUID( return CacheShards[Hash % NumShards]; } +void DependencyScanningFilesystemSharedCache:: + diagnoseInvalidNegativeStatCachedPaths( + std::vector<std::string> &InvalidPaths, + llvm::vfs::FileSystem &UnderlyingFS) const { + // Iterate through all shards and look for cached stat errors. + for (unsigned i = 0; i < NumShards; i++) { + const CacheShard &Shard = CacheShards[i]; + std::lock_guard<std::mutex> LockGuard(Shard.CacheLock); + for (const auto &[Path, CachedPair] : Shard.CacheByFilename) { + const CachedFileSystemEntry *Entry = CachedPair.first; + + if (Entry->getError()) { + // Only examine cached errors. + llvm::ErrorOr<llvm::vfs::Status> Stat = UnderlyingFS.status(Path); + if (Stat) { + // This is the case where we have cached the non-existence + // of the file at Path first, and a a file at the path is created + // later. The cache entry is not invalidated (as we have no good + // way to do it now), which may lead to missing file build errors. + InvalidPaths.push_back(std::string(Path)); ---------------- qiongsiwu wrote:
Sure! Fixed. I think it might be less burdensome for the client to not worry about how to allocate the string, but I don't have a strong opinion on this. Is it a performance reason where we do not want to allocate the strings here so the client can save the allocation if necessary? https://github.com/llvm/llvm-project/pull/135703 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits