clang 22.0.0git
clang::tooling::dependencies::DependencyScanningWorkerFilesystem Class Reference

A virtual file system optimized for the dependency discovery. More...

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

Inheritance diagram for clang::tooling::dependencies::DependencyScanningWorkerFilesystem:
[legend]

Public Member Functions

 DependencyScanningWorkerFilesystem (DependencyScanningFilesystemSharedCache &SharedCache, IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS)
llvm::ErrorOr< llvm::vfs::Status > status (const Twine &Path) override
llvm::ErrorOr< std::unique_ptr< llvm::vfs::File > > openFileForRead (const Twine &Path) override
std::error_code getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) override
std::error_code setCurrentWorkingDirectory (const Twine &Path) override
void resetBypassedPathPrefix ()
 Make it so that no paths bypass this VFS.
void setBypassedPathPrefix (StringRef Prefix)
 Set the prefix for paths that should bypass this VFS and go straight to the underlying VFS.
llvm::ErrorOr< EntryRefgetOrCreateFileSystemEntry (StringRef Filename)
 Returns entry for the given filename.
bool ensureDirectiveTokensArePopulated (EntryRef Entry)
 Ensure the directive tokens are populated for this file entry.
std::optional< ArrayRef< dependency_directives_scan::Directive > > getDirectiveTokens (const Twine &Path)
bool exists (const Twine &Path) override
 Check whether Path exists.

Static Public Attributes

static const char ID = 0

Detailed Description

A virtual file system optimized for the dependency discovery.

It is primarily designed to work with source files whose contents 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.

Definition at line 367 of file DependencyScanningFilesystem.h.

Constructor & Destructor Documentation

◆ DependencyScanningWorkerFilesystem()

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

Member Function Documentation

◆ ensureDirectiveTokensArePopulated()

bool DependencyScanningWorkerFilesystem::ensureDirectiveTokensArePopulated ( EntryRef Entry)

Ensure the directive tokens are populated for this file entry.

Returns true if the directive tokens are populated for this file entry, false if not (i.e. this entry is not a file or its scan fails).

Definition at line 43 of file DependencyScanningFilesystem.cpp.

References clang::tooling::dependencies::CachedFileContents::DepDirectives, clang::tooling::dependencies::CachedFileContents::DepDirectiveTokens, clang::tooling::dependencies::CachedFileContents::Original, clang::scanSourceForDependencyDirectives(), and clang::tooling::dependencies::CachedFileContents::ValueLock.

Referenced by getDirectiveTokens().

◆ exists()

bool DependencyScanningWorkerFilesystem::exists ( const Twine & Path)
override

Check whether Path exists.

By default checks cached result of status(), and falls back on FS if unable to do so.

Definition at line 341 of file DependencyScanningFilesystem.cpp.

References status().

◆ getDirectiveTokens()

std::optional< ArrayRef< dependency_directives_scan::Directive > > clang::tooling::dependencies::DependencyScanningWorkerFilesystem::getDirectiveTokens ( const Twine & Path)
inline
Returns
The scanned preprocessor directive tokens of the file that are used to speed up preprocessing, if available.

Definition at line 407 of file DependencyScanningFilesystem.h.

References ensureDirectiveTokensArePopulated(), and getOrCreateFileSystemEntry().

◆ getOrCreateFileSystemEntry()

llvm::ErrorOr< EntryRef > DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry ( StringRef Filename)

Returns entry for the given filename.

Attempts to use the local and shared caches first, then falls back to using the underlying filesystem.

Definition at line 311 of file DependencyScanningFilesystem.cpp.

References clang::tooling::dependencies::EntryRef::unwrapError().

Referenced by getDirectiveTokens(), openFileForRead(), and status().

◆ getRealPath()

std::error_code DependencyScanningWorkerFilesystem::getRealPath ( const Twine & Path,
SmallVectorImpl< char > & Output )
override

Definition at line 413 of file DependencyScanningFilesystem.cpp.

◆ openFileForRead()

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

◆ resetBypassedPathPrefix()

void clang::tooling::dependencies::DependencyScanningWorkerFilesystem::resetBypassedPathPrefix ( )
inline

Make it so that no paths bypass this VFS.

Definition at line 387 of file DependencyScanningFilesystem.h.

◆ setBypassedPathPrefix()

void clang::tooling::dependencies::DependencyScanningWorkerFilesystem::setBypassedPathPrefix ( StringRef Prefix)
inline

Set the prefix for paths that should bypass this VFS and go straight to the underlying VFS.

Definition at line 390 of file DependencyScanningFilesystem.h.

◆ setCurrentWorkingDirectory()

std::error_code DependencyScanningWorkerFilesystem::setCurrentWorkingDirectory ( const Twine & Path)
override

Definition at line 463 of file DependencyScanningFilesystem.cpp.

◆ status()

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

Definition at line 328 of file DependencyScanningFilesystem.cpp.

References getOrCreateFileSystemEntry(), and clang::Result.

Referenced by exists().

Member Data Documentation

◆ ID

const char DependencyScanningWorkerFilesystem::ID = 0
static

Definition at line 371 of file DependencyScanningFilesystem.h.


The documentation for this class was generated from the following files: