clang 24.0.0git
clang::dependencies::DependencyScanningWorker Class Reference

An individual dependency scanning worker that is able to run on its own thread. More...

#include "clang/DependencyScanning/DependencyScanningWorker.h"

Public Member Functions

 DependencyScanningWorker (DependencyScanningService &Service)
 Construct a dependency scanning worker.
 ~DependencyScanningWorker ()
bool computeDependencies (StringRef WorkingDirectory, ArrayRef< ArrayRef< std::string > > CommandLines, DependencyConsumer &DepConsumer, DependencyActionController &Controller, DiagnosticConsumer &DiagConsumer, IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS=nullptr)
 Run the dependency scanning tool for all given frontend command-lines, and report the discovered dependencies to the provided consumer.
bool computeDependenciesByName (StringRef CWD, ArrayRef< std::string > CC1CommandLine, IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS, DiagnosticConsumer &DiagConsumer, DependencyActionController &Controller, llvm::function_ref< std::optional< std::string >()> getNextName, DependencyConsumer &DepConsumer)
 By-name scanning over a single cc1 command line.
IntrusiveRefCntPtr< llvm::vfs::FileSystem > makeEffectiveVFS (StringRef WorkingDirectory, IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS=nullptr) const
 Creates the effective VFS that will be used for the scan.
llvm::vfs::TracingFileSystem * getTracingVFS () const
 Returns the worker tracing VFS, if it was requested via the service.

Static Public Attributes

static const int32_t MaxNumOfByNameQueries = 1 << 16

Friends

class CompilerInstanceWithContext

Detailed Description

An individual dependency scanning worker that is able to run on its own thread.

The worker computes the dependencies for the input files by preprocessing sources either using a fast mode where the source files are minimized, or using the regular processing run.

Definition at line 45 of file DependencyScanningWorker.h.

Constructor & Destructor Documentation

◆ DependencyScanningWorker()

DependencyScanningWorker::DependencyScanningWorker ( DependencyScanningService & Service)

Construct a dependency scanning worker.

Parameters
ServiceThe parent service. Must outlive the worker.

Definition at line 992 of file DependencyScanningWorker.cpp.

◆ ~DependencyScanningWorker()

DependencyScanningWorker::~DependencyScanningWorker ( )
default

Member Function Documentation

◆ computeDependencies()

bool DependencyScanningWorker::computeDependencies ( StringRef WorkingDirectory,
ArrayRef< ArrayRef< std::string > > CommandLines,
DependencyConsumer & DepConsumer,
DependencyActionController & Controller,
DiagnosticConsumer & DiagConsumer,
IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS = nullptr )

Run the dependency scanning tool for all given frontend command-lines, and report the discovered dependencies to the provided consumer.

The OverlayFS will be used to call makeEffectiveVFS().

Returns
false if any errors occurred (with diagnostics reported to DiagConsumer), true otherwise.

Definition at line 1031 of file DependencyScanningWorker.cpp.

References any(), canonicalizeDefines(), createCompilerInvocation(), clang::CompilerInstance::createDiagnostics(), clang::dependencies::createScanningDiagOptions(), clang::dependencies::DependencyConsumer::handleBuildCommand(), clang::dependencies::CompilerInstanceWithContext::initializeFromCC1Commandline(), clang::dependencies::Macros, makeEffectiveVFS(), clang::Result, and clang::Success.

◆ computeDependenciesByName()

bool DependencyScanningWorker::computeDependenciesByName ( StringRef CWD,
ArrayRef< std::string > CC1CommandLine,
IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS,
DiagnosticConsumer & DiagConsumer,
DependencyActionController & Controller,
llvm::function_ref< std::optional< std::string >()> getNextName,
DependencyConsumer & DepConsumer )

By-name scanning over a single cc1 command line.

Builds a scanning session local to this call, then pulls module names from getNextName until it returns std::nullopt. Results flow to DepConsumer (per-name status via finishQuery); diagnostics flow to DiagConsumer.

Returns
false if session setup failed, true otherwise.

Definition at line 1096 of file DependencyScanningWorker.cpp.

References clang::CompilerInstance::createDiagnostics(), clang::dependencies::createScanningDiagOptions(), clang::dependencies::DependencyConsumer::finishQuery(), clang::dependencies::CompilerInstanceWithContext::initializeFromCC1Commandline(), makeEffectiveVFS(), and clang::Success.

◆ getTracingVFS()

llvm::vfs::TracingFileSystem * clang::dependencies::DependencyScanningWorker::getTracingVFS ( ) const
inline

Returns the worker tracing VFS, if it was requested via the service.

Definition at line 89 of file DependencyScanningWorker.h.

◆ makeEffectiveVFS()

IntrusiveRefCntPtr< llvm::vfs::FileSystem > DependencyScanningWorker::makeEffectiveVFS ( StringRef WorkingDirectory,
IntrusiveRefCntPtr< llvm::vfs::FileSystem > OverlayFS = nullptr ) const

Creates the effective VFS that will be used for the scan.

If provided, OverlayFS will be overlaid on top of the Worker's dependency scanning file-system and can be used to provide any input specified on the command-line as in-memory file. If no overlay file-system is provided, the Worker's dependency scanning file-system is used directly.

Definition at line 1017 of file DependencyScanningWorker.cpp.

Referenced by computeDependencies(), and computeDependenciesByName().

◆ CompilerInstanceWithContext

friend class CompilerInstanceWithContext
friend

Definition at line 112 of file DependencyScanningWorker.h.

References CompilerInstanceWithContext.

Referenced by CompilerInstanceWithContext.

Member Data Documentation

◆ MaxNumOfByNameQueries

const int32_t clang::dependencies::DependencyScanningWorker::MaxNumOfByNameQueries = 1 << 16
static

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