clang 22.0.0git
clang::tooling::StandaloneToolExecutor Class Reference

A standalone executor that runs FrontendActions on a given set of TUs in sequence. More...

#include "clang/Tooling/StandaloneExecution.h"

Inheritance diagram for clang::tooling::StandaloneToolExecutor:
[legend]

Public Member Functions

 StandaloneToolExecutor (const CompilationDatabase &Compilations, llvm::ArrayRef< std::string > SourcePaths, IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS=llvm::vfs::getRealFileSystem(), std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
 Init with CompilationDatabase and the paths of all files to be proccessed.
 StandaloneToolExecutor (CommonOptionsParser Options, std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
 Init with CommonOptionsParser.
StringRef getExecutorName () const override
 Returns the name of a specific executor.
llvm::Error execute (llvm::ArrayRef< std::pair< std::unique_ptr< FrontendActionFactory >, ArgumentsAdjuster > > Actions) override
 Executes each action with a corresponding arguments adjuster.
void setDiagnosticConsumer (DiagnosticConsumer *DiagConsumer)
 Set a DiagnosticConsumer to use during parsing.
ExecutionContextgetExecutionContext () override
 Returns a reference to the execution context.
ToolResultsgetToolResults () override
 Returns a reference to the result container.
llvm::ArrayRef< std::string > getSourcePaths () const
void mapVirtualFile (StringRef FilePath, StringRef Content) override
 Map a virtual file to be used while running the tool.
FileManagergetFiles ()
 Returns the file manager used in the tool.
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action)
 Convenient functions for the above execute.
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action, ArgumentsAdjuster Adjuster)
 Executes an action with an argument adjuster.
Public Member Functions inherited from clang::tooling::ToolExecutor
virtual ~ToolExecutor ()
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action)
 Convenient functions for the above execute.
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action, ArgumentsAdjuster Adjuster)
 Executes an action with an argument adjuster.

Static Public Attributes

static const char * ExecutorName = "StandaloneToolExecutor"

Detailed Description

A standalone executor that runs FrontendActions on a given set of TUs in sequence.

By default, this executor uses the following arguments adjusters (as defined in clang/Tooling/ArgumentsAdjusters.h):

Definition at line 31 of file StandaloneExecution.h.

Constructor & Destructor Documentation

◆ StandaloneToolExecutor() [1/2]

clang::tooling::StandaloneToolExecutor::StandaloneToolExecutor ( const CompilationDatabase & Compilations,
llvm::ArrayRef< std::string > SourcePaths,
IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS = llvm::vfs::getRealFileSystem(),
std::shared_ptr< PCHContainerOperations > PCHContainerOps = std::make_shared<PCHContainerOperations>() )

Init with CompilationDatabase and the paths of all files to be proccessed.

Definition at line 29 of file StandaloneExecution.cpp.

References clang::tooling::getDefaultArgumentsAdjusters().

◆ StandaloneToolExecutor() [2/2]

clang::tooling::StandaloneToolExecutor::StandaloneToolExecutor ( CommonOptionsParser Options,
std::shared_ptr< PCHContainerOperations > PCHContainerOps = std::make_shared<PCHContainerOperations>() )

Init with CommonOptionsParser.

This is expected to be used by createExecutorFromCommandLineArgs based on commandline options.

The executor takes ownership of Options.

Definition at line 42 of file StandaloneExecution.cpp.

References clang::tooling::getDefaultArgumentsAdjusters().

Member Function Documentation

◆ execute() [1/3]

llvm::Error clang::tooling::StandaloneToolExecutor::execute ( llvm::ArrayRef< std::pair< std::unique_ptr< FrontendActionFactory >, ArgumentsAdjuster > > Actions)
overridevirtual

Executes each action with a corresponding arguments adjuster.

Implements clang::tooling::ToolExecutor.

Definition at line 52 of file StandaloneExecution.cpp.

References clang::tooling::make_string_error().

◆ execute() [2/3]

llvm::Error clang::tooling::ToolExecutor::execute ( std::unique_ptr< FrontendActionFactory > Action)

Convenient functions for the above execute.

Definition at line 125 of file Execution.cpp.

◆ execute() [3/3]

llvm::Error clang::tooling::ToolExecutor::execute ( std::unique_ptr< FrontendActionFactory > Action,
ArgumentsAdjuster Adjuster )

Executes an action with an argument adjuster.

Definition at line 127 of file Execution.cpp.

◆ getExecutionContext()

ExecutionContext * clang::tooling::StandaloneToolExecutor::getExecutionContext ( )
inlineoverridevirtual

Returns a reference to the execution context.

This should be passed to tool callbacks, and tool callbacks should report results via the returned context.

Implements clang::tooling::ToolExecutor.

Definition at line 68 of file StandaloneExecution.h.

◆ getExecutorName()

StringRef clang::tooling::StandaloneToolExecutor::getExecutorName ( ) const
inlineoverridevirtual

Returns the name of a specific executor.

Implements clang::tooling::ToolExecutor.

Definition at line 54 of file StandaloneExecution.h.

References ExecutorName.

◆ getFiles()

FileManager & clang::tooling::StandaloneToolExecutor::getFiles ( )
inline

Returns the file manager used in the tool.

The file manager is shared between all translation units.

Definition at line 83 of file StandaloneExecution.h.

◆ getSourcePaths()

llvm::ArrayRef< std::string > clang::tooling::StandaloneToolExecutor::getSourcePaths ( ) const
inline

Definition at line 72 of file StandaloneExecution.h.

◆ getToolResults()

ToolResults * clang::tooling::StandaloneToolExecutor::getToolResults ( )
inlineoverridevirtual

Returns a reference to the result container.

NOTE: This should only be used after the execution finishes. Tool callbacks should report results via ExecutionContext instead.

Implements clang::tooling::ToolExecutor.

Definition at line 70 of file StandaloneExecution.h.

◆ mapVirtualFile()

void clang::tooling::StandaloneToolExecutor::mapVirtualFile ( StringRef FilePath,
StringRef Content )
inlineoverridevirtual

Map a virtual file to be used while running the tool.

Parameters
FilePathThe path at which the content will be mapped.
ContentA buffer of the file's content.

Implements clang::tooling::ToolExecutor.

Definition at line 76 of file StandaloneExecution.h.

◆ setDiagnosticConsumer()

void clang::tooling::StandaloneToolExecutor::setDiagnosticConsumer ( DiagnosticConsumer * DiagConsumer)
inline

Set a DiagnosticConsumer to use during parsing.

Definition at line 64 of file StandaloneExecution.h.

Member Data Documentation

◆ ExecutorName

const char * clang::tooling::StandaloneToolExecutor::ExecutorName = "StandaloneToolExecutor"
static

Definition at line 33 of file StandaloneExecution.h.

Referenced by getExecutorName().


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