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

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

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

Public Member Functions

 DependencyScanningWorker (DependencyScanningService &Service, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS)
 Construct a dependency scanning worker.
 ~DependencyScanningWorker ()
bool computeDependencies (StringRef WorkingDirectory, const std::vector< 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.
llvm::Error computeDependencies (StringRef WorkingDirectory, const std::vector< std::string > &CommandLine, DependencyConsumer &Consumer, DependencyActionController &Controller, std::optional< llvm::MemoryBufferRef > TUBuffer=std::nullopt)
 Run the dependency scanning tool for a given clang driver command-line for a specific translation unit via file system or memory buffer.
llvm::Error initializeCompilerInstanceWithContextOrError (StringRef CWD, const std::vector< std::string > &CommandLine)
 The three method below implements a new interface for by name dependency scanning.
llvm::Error computeDependenciesByNameWithContextOrError (StringRef ModuleName, DependencyConsumer &Consumer, DependencyActionController &Controller)
 Performaces dependency scanning for the module whose name is specified.
llvm::Error finalizeCompilerInstanceWithContextOrError ()
 Finalizes the diagnostics engine and deletes the compiler instance.
bool initializeCompilerInstanceWithContext (StringRef CWD, const std::vector< std::string > &CommandLine, DiagnosticConsumer *DC=nullptr)
 The three methods below provides the same functionality as the three methods above.
bool computeDependenciesByNameWithContext (StringRef ModuleName, DependencyConsumer &Consumer, DependencyActionController &Controller)
bool finalizeCompilerInstance ()
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 84 of file DependencyScanningWorker.h.

Constructor & Destructor Documentation

◆ DependencyScanningWorker()

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

Construct a dependency scanning worker.

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

Definition at line 19 of file DependencyScanningWorker.cpp.

References clang::tooling::dependencies::CanonicalPreprocessing, and clang::tooling::dependencies::DependencyDirectivesScan.

◆ ~DependencyScanningWorker()

DependencyScanningWorker::~DependencyScanningWorker ( )
default

Member Function Documentation

◆ computeDependencies() [1/2]

llvm::Error DependencyScanningWorker::computeDependencies ( StringRef WorkingDirectory,
const std::vector< std::string > & CommandLine,
DependencyConsumer & Consumer,
DependencyActionController & Controller,
std::optional< llvm::MemoryBufferRef > TUBuffer = std::nullopt )

Run the dependency scanning tool for a given clang driver command-line for a specific translation unit via file system or memory buffer.

Returns
A StringError with the diagnostic output if clang errors occurred, success otherwise.

Definition at line 49 of file DependencyScanningWorker.cpp.

References computeDependencies(), clang::tooling::dependencies::TextDiagnosticsPrinterWithOutput::DiagnosticsOS, and clang::tooling::dependencies::TextDiagnosticsPrinterWithOutput::DiagPrinter.

◆ computeDependencies() [2/2]

bool DependencyScanningWorker::computeDependencies ( StringRef WorkingDirectory,
const std::vector< 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 155 of file DependencyScanningWorker.cpp.

References clang::tooling::dependencies::initVFSForTUBufferScanning().

Referenced by computeDependencies().

◆ computeDependenciesByNameWithContext()

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

◆ computeDependenciesByNameWithContextOrError()

llvm::Error DependencyScanningWorker::computeDependenciesByNameWithContextOrError ( 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
Error if the scanner incurs errors.

Definition at line 179 of file DependencyScanningWorker.cpp.

References computeDependenciesByNameWithContext(), and clang::Success.

◆ finalizeCompilerInstance()

bool DependencyScanningWorker::finalizeCompilerInstance ( )

◆ finalizeCompilerInstanceWithContextOrError()

llvm::Error DependencyScanningWorker::finalizeCompilerInstanceWithContextOrError ( )

Finalizes the diagnostics engine and deletes the compiler instance.

Returns
Error if errors occur during finalization.

Definition at line 188 of file DependencyScanningWorker.cpp.

References finalizeCompilerInstance(), and clang::Success.

◆ getVFS()

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

Definition at line 160 of file DependencyScanningWorker.h.

◆ initializeCompilerInstanceWithContext()

bool DependencyScanningWorker::initializeCompilerInstanceWithContext ( StringRef CWD,
const std::vector< std::string > & CommandLine,
DiagnosticConsumer * DC = nullptr )

The three methods below provides the same functionality as the three methods above.

Instead of returning llvm::Errors, these three methods return a flag to indicate if the call is successful. The initialization function asks the client for a DiagnosticsConsumer that it direct the diagnostics to.

Definition at line 193 of file DependencyScanningWorker.cpp.

Referenced by initializeCompilerInstanceWithContextOrError().

◆ initializeCompilerInstanceWithContextOrError()

llvm::Error DependencyScanningWorker::initializeCompilerInstanceWithContextOrError ( StringRef CWD,
const std::vector< std::string > & CommandLine )

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.

Initializing the context and the compiler instance.

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

Definition at line 172 of file DependencyScanningWorker.cpp.

References initializeCompilerInstanceWithContext(), and clang::Success.


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