clang 22.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, IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS)
 Construct a dependency scanning worker.
 ~DependencyScanningWorker ()
bool computeDependencies (StringRef WorkingDirectory, ArrayRef< std::string > CommandLine, DependencyConsumer &DepConsumer, DependencyActionController &Controller, DiagnosticConsumer &DiagConsumer, std::optional< llvm::MemoryBufferRef > TUBuffer=std::nullopt)
 Run the dependency scanning tool for a given clang driver command-line, and report the discovered dependencies to the provided consumer.
bool initializeCompilerInstanceWithContext (StringRef CWD, ArrayRef< std::string > CommandLine, DiagnosticConsumer &DC)
 The three method below implements a new interface for by name dependency scanning.
bool initializeCompilerInstanceWithContext (StringRef CWD, ArrayRef< std::string > CommandLine, std::unique_ptr< DiagnosticsEngineWithDiagOpts > DiagEngineWithCmdAndOpts, IntrusiveRefCntPtr< llvm::vfs::OverlayFileSystem > OverlayFS)
 Initializing the context and the compiler instance.
bool computeDependenciesByNameWithContext (StringRef ModuleName, DependencyConsumer &Consumer, DependencyActionController &Controller)
 Performaces dependency scanning for the module whose name is specified.
bool finalizeCompilerInstanceWithContext ()
 Finalizes the diagnostics engine and deletes the compiler instance.
llvm::vfs::FileSystem & getVFS () const

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 85 of file DependencyScanningWorker.h.

Constructor & Destructor Documentation

◆ DependencyScanningWorker()

DependencyScanningWorker::DependencyScanningWorker ( DependencyScanningService & Service,
IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS )

Construct a dependency scanning worker.

Parameters
ServiceThe parent service. Must outlive the worker.
BaseFSThe filesystem for the worker to use.

Definition at line 21 of file DependencyScanningWorker.cpp.

◆ ~DependencyScanningWorker()

DependencyScanningWorker::~DependencyScanningWorker ( )
default

Member Function Documentation

◆ computeDependencies()

bool DependencyScanningWorker::computeDependencies ( StringRef WorkingDirectory,
ArrayRef< std::string > CommandLine,
DependencyConsumer & DepConsumer,
DependencyActionController & Controller,
DiagnosticConsumer & DiagConsumer,
std::optional< llvm::MemoryBufferRef > TUBuffer = std::nullopt )

Run the dependency scanning tool for a given clang driver command-line, and report the discovered dependencies to the provided consumer.

If TUBuffer is not nullopt, it is used as TU input for the dependency scanning. Otherwise, the input should be included as part of the command-line.

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

Definition at line 140 of file DependencyScanningWorker.cpp.

References clang::dependencies::initVFSForTUBufferScanning().

◆ computeDependenciesByNameWithContext()

bool DependencyScanningWorker::computeDependenciesByNameWithContext ( StringRef ModuleName,
DependencyConsumer & Consumer,
DependencyActionController & Controller )

Performaces dependency scanning for the module whose name is specified.

Parameters
ModuleNameThe name of the module whose dependency will be scanned.
ConsumerThe dependency consumer that stores the results.
ControllerThe controller for the dependency scanning action.
Returns
False if the scanner incurs errors.

Definition at line 177 of file DependencyScanningWorker.cpp.

◆ finalizeCompilerInstanceWithContext()

bool DependencyScanningWorker::finalizeCompilerInstanceWithContext ( )

Finalizes the diagnostics engine and deletes the compiler instance.

Returns
False if errors occur during finalization.

Definition at line 184 of file DependencyScanningWorker.cpp.

◆ getVFS()

llvm::vfs::FileSystem & clang::dependencies::DependencyScanningWorker::getVFS ( ) const
inline

Definition at line 153 of file DependencyScanningWorker.h.

◆ initializeCompilerInstanceWithContext() [1/2]

bool DependencyScanningWorker::initializeCompilerInstanceWithContext ( StringRef CWD,
ArrayRef< std::string > CommandLine,
DiagnosticConsumer & DC )

The three method below implements a new interface for by name dependency scanning.

They together enable the dependency scanning worker to more effectively perform scanning for a sequence of modules by name when the CWD and CommandLine do not change across the queries. The initialization function asks the client for a DiagnosticsConsumer that it direct the diagnostics to.

Initializing the context and the compiler instance.

Parameters
CWDThe current working directory used during the scan.
CommandLineThe commandline used for the scan.
Returns
False if the initializaiton fails.

Definition at line 156 of file DependencyScanningWorker.cpp.

References initializeCompilerInstanceWithContext(), and clang::dependencies::initVFSForByNameScanning().

Referenced by initializeCompilerInstanceWithContext().

◆ initializeCompilerInstanceWithContext() [2/2]

bool DependencyScanningWorker::initializeCompilerInstanceWithContext ( StringRef CWD,
ArrayRef< std::string > CommandLine,
std::unique_ptr< DiagnosticsEngineWithDiagOpts > DiagEngineWithCmdAndOpts,
IntrusiveRefCntPtr< llvm::vfs::OverlayFileSystem > OverlayFS )

Initializing the context and the compiler instance.

Parameters
CWDThe current working directory used during the scan.
CommandLineThe commandline used for the scan.
DiagEngineWithCmdAndOptsPreconfigured diagnostics engine and options associated with the cc1 command line.
FSThe overlay file system to use for this compiler instance.
Returns
False if the initializaiton fails.

Definition at line 167 of file DependencyScanningWorker.cpp.


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