[PATCH] D68193: In openFileForRead don't cache erroneous entries if the error relates to them being directories. Add tests.

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 18:20:54 PDT 2019


arphaman added a comment.

I don't quite understand the specific issue you're hitting, as it sounds that the logic right now should handle it:

> It seems that when the CachingFileSystem is first given a file to open that is actually a directory, it incorrectly
> caches that path to be errenous and throws an error when subsequently a directory open >call is made for the same
> path.

In this case, right now (without this patch) `createFileEntry` will return `std::errc::is_a_directory`. `DependencyScanningWorkerFilesystem::openFileForRead` will then invalidate the entry in the global cache:

  if (CacheEntry.getError() == std::errc::is_a_directory) {
      // Reset the CacheEntry to avoid setting an error entry in the
      // cache for the given directory path.
      CacheEntry = CachedFileSystemEntry();

Which means that when the call to `stat` happens, it should be fine as the global cache doesn't have a valid entry, so it will be able to recognize a directory and won't return an error.

Does this not happen in your case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68193/new/

https://reviews.llvm.org/D68193





More information about the cfe-commits mailing list