clang  6.0.0svn
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]
Collaboration diagram for clang::tooling::StandaloneToolExecutor:
Collaboration graph
[legend]

Public Member Functions

 StandaloneToolExecutor (const CompilationDatabase &Compilations, llvm::ArrayRef< std::string > SourcePaths, 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...
 
- 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,
std::shared_ptr< PCHContainerOperations PCHContainerOps = std::make_shared<PCHContainerOperations>() 
)

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

Definition at line 30 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 41 of file StandaloneExecution.cpp.

Member Function Documentation

◆ execute()

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 51 of file StandaloneExecution.cpp.

References clang::tooling::make_string_error().

Referenced by getExecutorName().

◆ 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 66 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 52 of file StandaloneExecution.h.

References clang::Error, execute(), clang::tooling::ToolExecutor::execute(), and 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 81 of file StandaloneExecution.h.

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

◆ getSourcePaths()

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

Definition at line 70 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 68 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 74 of file StandaloneExecution.h.

◆ setDiagnosticConsumer()

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

Set a DiagnosticConsumer to use during parsing.

Definition at line 62 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(), and clang::tooling::make_string_error().


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