Skip to content

Commit e73e72a

Browse files
committed
[clang][deps] Overload 'Filesystem::exists' in 'DependencyScanningFilesystem' to have it use cached status
As-is, calls to `exists()` fallback on the implementation in 'ProxyFileSystem::exists' which explicitly calls out to the underlying `FS`, which for the 'DependencyScanningFilesystem' (overlay) is the real underlying filesystem. Instead, directly overloading 'exists' allows us to have it rely on the cached `status` behavior used elsewhere by the 'DependencyScanningFilesystem'.
1 parent c2b2cd0 commit e73e72a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ class DependencyScanningWorkerFilesystem
365365
return LocalCache.insertEntryForFilename(Filename, Entry);
366366
}
367367

368+
/// Check whether \p Path exists. By default checks cached result of \c status(),
369+
/// and falls back on FS if unable to do so.
370+
bool exists(const Twine &Path) override;
371+
368372
/// Returns entry associated with the filename in the shared cache if there is
369373
/// some. Otherwise, constructs new one with the given error code, associates
370374
/// it with the filename and returns the result.

clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ DependencyScanningWorkerFilesystem::status(const Twine &Path) {
270270
return Result->getStatus();
271271
}
272272

273+
bool
274+
DependencyScanningWorkerFilesystem::exists(const Twine &Path) {
275+
auto Status = status(Path);
276+
return Status && Status->exists();
277+
}
278+
273279
namespace {
274280

275281
/// The VFS that is used by clang consumes the \c CachedFileSystemEntry using

0 commit comments

Comments
 (0)