clang 23.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, llvm::IntrusiveRefCntPtr< llvm::vfs::OverlayFileSystem > OverlayFS=nullptr)
 Run the dependency scanning worker for the given frontend command-line, and report the discovered dependencies to the provided consumer.
bool computeDependencies (StringRef WorkingDirectory, ArrayRef< ArrayRef< std::string > > CommandLines, DependencyConsumer &DepConsumer, DependencyActionController &Controller, DiagnosticConsumer &DiagConsumer, llvm::IntrusiveRefCntPtr< llvm::vfs::OverlayFileSystem > OverlayFS=nullptr)
 Run the dependency scanning tool for all given frontend command-lines, 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 22 of file DependencyScanningWorker.cpp.

◆ ~DependencyScanningWorker()

DependencyScanningWorker::~DependencyScanningWorker ( )
default

Member Function Documentation

◆ computeDependencies() [1/2]

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

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

OverlayFS should be based on 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 instead.

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

Definition at line 68 of file DependencyScanningWorker.cpp.

References createAndRunToolInvocation(), clang::DiagnosticConsumer::finish(), clang::dependencies::DependencyConsumer::handleBuildCommand(), clang::dependencies::DependencyScanningAction::hasDiagConsumerFinished(), clang::dependencies::DependencyScanningAction::hasScanned(), clang::Success, and clang::dependencies::VFS.

◆ computeDependencies() [2/2]

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

Run the dependency scanning worker for the given frontend command-line, and report the discovered dependencies to the provided consumer.

OverlayFS should be based on 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 instead.

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

Definition at line 58 of file DependencyScanningWorker.cpp.

References computeDependencies().

Referenced by computeDependencies().

◆ 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 136 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 143 of file DependencyScanningWorker.cpp.

◆ getVFS()

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

Definition at line 173 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 115 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 126 of file DependencyScanningWorker.cpp.


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