class DependencyScanningWorkerFilesystem

Declaration

class DependencyScanningWorkerFilesystem : public ProxyFileSystem { /* full declaration omitted */ };

Description

A virtual file system optimized for the dependency discovery. It is primarily designed to work with source files whose contents was was preprocessed to remove any tokens that are unlikely to affect the dependency computation. This is not a thread safe VFS. A single instance is meant to be used only in one thread. Multiple instances are allowed to service multiple threads running in parallel.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:281

Inherits from: ProxyFileSystem

Member Variables

private clang::tooling::dependencies:: DependencyScanningFilesystemSharedCache& SharedCache
The global cache shared between worker threads.
private clang::tooling::dependencies:: DependencyScanningFilesystemLocalCache LocalCache
The local cache is used by the worker thread to cache file system queries locally instead of querying the global cache every time.

Method Overview

  • public DependencyScanningWorkerFilesystem(clang::tooling::dependencies::DependencyScanningFilesystemSharedCache & SharedCache, IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
  • private llvm::ErrorOr<const CachedFileSystemEntry &> computeAndStoreResult(llvm::StringRef Filename)
  • private const clang::tooling::dependencies::CachedFileSystemEntry * findEntryByFilenameWithWriteThrough(llvm::StringRef Filename)
  • private const clang::tooling::dependencies::CachedFileSystemEntry * findSharedEntryByUID(llvm::vfs::Status Stat) const
  • public llvm::ErrorOr<EntryRef> getOrCreateFileSystemEntry(llvm::StringRef Filename, bool DisableDirectivesScanning = false)
  • private const clang::tooling::dependencies::CachedFileSystemEntry & getOrEmplaceSharedEntryForFilename(llvm::StringRef Filename, std::error_code EC)
  • private const clang::tooling::dependencies::CachedFileSystemEntry & getOrEmplaceSharedEntryForUID(clang::tooling::dependencies::DependencyScanningWorkerFilesystem::TentativeEntry TEntry)
  • private const clang::tooling::dependencies::CachedFileSystemEntry & getOrInsertSharedEntryForFilename(llvm::StringRef Filename, const clang::tooling::dependencies::CachedFileSystemEntry & Entry)
  • private const clang::tooling::dependencies::CachedFileSystemEntry & insertLocalEntryForFilename(llvm::StringRef Filename, const clang::tooling::dependencies::CachedFileSystemEntry & Entry)
  • public llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> openFileForRead(const llvm::Twine & Path)
  • private llvm::ErrorOr<TentativeEntry> readFile(llvm::StringRef Filename)
  • private clang::tooling::dependencies::EntryRef scanForDirectivesIfNecessary(const clang::tooling::dependencies::CachedFileSystemEntry & Entry, llvm::StringRef Filename, bool Disable)
  • private bool shouldScanForDirectives(llvm::StringRef Filename)
  • public llvm::ErrorOr<llvm::vfs::Status> status(const llvm::Twine & Path)

Inherited from ProxyFileSystem:

Inherited from FileSystem:

Methods

DependencyScanningWorkerFilesystem(
    clang::tooling::dependencies::
        DependencyScanningFilesystemSharedCache&
            SharedCache,
    IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:283

Parameters

clang::tooling::dependencies:: DependencyScanningFilesystemSharedCache& SharedCache
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS

llvm::ErrorOr<const CachedFileSystemEntry&>
computeAndStoreResult(llvm::StringRef Filename)

Description

For a filename that's not yet associated with any entry in the caches, uses the underlying filesystem to either look up the entry based in the shared cache indexed by unique ID, or creates new entry from scratch.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:308

Parameters

llvm::StringRef Filename

const clang::tooling::dependencies::
    CachedFileSystemEntry*
    findEntryByFilenameWithWriteThrough(
        llvm::StringRef Filename)

Description

Returns entry associated with the filename or nullptr if none is found. Returns entry from local cache if there is some. Otherwise, if the entry is found in the shared cache, writes it through the local cache and returns it. Otherwise returns nullptr.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:342

Parameters

llvm::StringRef Filename

const clang::tooling::dependencies::
    CachedFileSystemEntry*
    findSharedEntryByUID(
        llvm::vfs::Status Stat) const

Description

Returns entry associated with the unique ID in the shared cache or nullptr if none is found.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:347

Parameters

llvm::vfs::Status Stat

llvm::ErrorOr<EntryRef>
getOrCreateFileSystemEntry(
    llvm::StringRef Filename,
    bool DisableDirectivesScanning = false)

Description

Returns entry for the given filename. Attempts to use the local and shared caches first, then falls back to using the underlying filesystem.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:297

Parameters

llvm::StringRef Filename
bool DisableDirectivesScanning = false

const clang::tooling::dependencies::
    CachedFileSystemEntry&
    getOrEmplaceSharedEntryForFilename(
        llvm::StringRef Filename,
        std::error_code EC)

Description

Returns entry associated with the filename in the shared cache if there is some. Otherwise, constructs new one with the given error code, associates it with the filename and returns the result.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:364

Parameters

llvm::StringRef Filename
std::error_code EC

const clang::tooling::dependencies::
    CachedFileSystemEntry&
    getOrEmplaceSharedEntryForUID(
        clang::tooling::dependencies::
            DependencyScanningWorkerFilesystem::
                TentativeEntry TEntry)

Description

Returns entry associated with the unique ID of the given tentative entry if there is some in the shared cache. Otherwise, constructs new one, associates it with the unique ID and returns the result.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:334

Parameters

clang::tooling::dependencies:: DependencyScanningWorkerFilesystem:: TentativeEntry TEntry

const clang::tooling::dependencies::
    CachedFileSystemEntry&
    getOrInsertSharedEntryForFilename(
        llvm::StringRef Filename,
        const clang::tooling::dependencies::
            CachedFileSystemEntry& Entry)

Description

Returns entry associated with the filename in the shared cache if there is some. Otherwise, associates the given entry with the filename and returns it.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:373

Parameters

llvm::StringRef Filename
const clang::tooling::dependencies:: CachedFileSystemEntry& Entry

const clang::tooling::dependencies::
    CachedFileSystemEntry&
    insertLocalEntryForFilename(
        llvm::StringRef Filename,
        const clang::tooling::dependencies::
            CachedFileSystemEntry& Entry)

Description

Associates the given entry with the filename in the local cache and returns it.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:355

Parameters

llvm::StringRef Filename
const clang::tooling::dependencies:: CachedFileSystemEntry& Entry

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const llvm::Twine& Path)

Description

Get a \p File object for the file at \p Path, if one exists.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:290

Parameters

const llvm::Twine& Path

llvm::ErrorOr<TentativeEntry> readFile(
    llvm::StringRef Filename)

Description

Reads file at the given path. Enforces consistency between the file size in status and size of read contents.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:328

Parameters

llvm::StringRef Filename

clang::tooling::dependencies::EntryRef
scanForDirectivesIfNecessary(
    const clang::tooling::dependencies::
        CachedFileSystemEntry& Entry,
    llvm::StringRef Filename,
    bool Disable)

Description

Scan for preprocessor directives for the given entry if necessary and returns a wrapper object with reference semantics.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:312

Parameters

const clang::tooling::dependencies:: CachedFileSystemEntry& Entry
llvm::StringRef Filename
bool Disable

bool shouldScanForDirectives(
    llvm::StringRef Filename)

Description

Check whether the file should be scanned for preprocessor directives.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:302

Parameters

llvm::StringRef Filename

llvm::ErrorOr<llvm::vfs::Status> status(
    const llvm::Twine& Path)

Description

Get the status of the entry at \p Path, if one exists.

Declared at: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:288

Parameters

const llvm::Twine& Path