clang  19.0.0git
Public Member Functions | Static Public Attributes | List of all members
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:
Inheritance graph
[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. More...
 
 StandaloneToolExecutor (CommonOptionsParser Options, std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
 Init with CommonOptionsParser. More...
 
StringRef getExecutorName () const override
 Returns the name of a specific executor. More...
 
llvm::Error execute (llvm::ArrayRef< std::pair< std::unique_ptr< FrontendActionFactory >, ArgumentsAdjuster >> Actions) override
 Executes each action with a corresponding arguments adjuster. More...
 
void setDiagnosticConsumer (DiagnosticConsumer *DiagConsumer)
 Set a DiagnosticConsumer to use during parsing. More...
 
ExecutionContextgetExecutionContext () override
 Returns a reference to the execution context. More...
 
ToolResultsgetToolResults () override
 Returns a reference to the result container. More...
 
llvm::ArrayRef< std::string > getSourcePaths () const
 
void mapVirtualFile (StringRef FilePath, StringRef Content) override
 Map a virtual file to be used while running the tool. More...
 
FileManagergetFiles ()
 Returns the file manager used in the tool. More...
 
virtual llvm::Error execute (llvm::ArrayRef< std::pair< std::unique_ptr< FrontendActionFactory >, ArgumentsAdjuster >> Actions)=0
 Executes each action with a corresponding arguments adjuster. More...
 
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action)
 Convenient functions for the above execute. More...
 
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action, ArgumentsAdjuster Adjuster)
 Executes an action with an argument adjuster. More...
 
- Public Member Functions inherited from clang::tooling::ToolExecutor
virtual ~ToolExecutor ()
 
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action)
 Convenient functions for the above execute. More...
 
llvm::Error execute (std::unique_ptr< FrontendActionFactory > Action, ArgumentsAdjuster Adjuster)
 Executes an action with an argument adjuster. More...
 

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.

◆ 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.

Member Function Documentation

◆ execute() [1/4]

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::ClangTool::appendArgumentsAdjuster(), clang::tooling::make_string_error(), and clang::tooling::ClangTool::run().

◆ execute() [2/4]

virtual llvm::Error clang::tooling::ToolExecutor::execute

Executes each action with a corresponding arguments adjuster.

◆ execute() [3/4]

llvm::Error clang::tooling::ToolExecutor::execute

Convenient functions for the above execute.

Definition at line 125 of file Execution.cpp.

◆ execute() [4/4]

llvm::Error clang::tooling::ToolExecutor::execute

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.

References clang::tooling::ClangTool::getFiles().

◆ getSourcePaths()

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

Definition at line 72 of file StandaloneExecution.h.

References clang::tooling::ClangTool::getSourcePaths().

◆ 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.

References clang::tooling::ClangTool::mapVirtualFile().

◆ setDiagnosticConsumer()

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

Set a DiagnosticConsumer to use during parsing.

Definition at line 64 of file StandaloneExecution.h.

References clang::tooling::ClangTool::setDiagnosticConsumer().

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: