class StandaloneToolExecutor

Declaration

class StandaloneToolExecutor : public ToolExecutor { /* full declaration omitted */ };

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`): - `getClangStripOutputAdjuster()` - `getClangSyntaxOnlyAdjuster()` - `getClangStripDependencyFileAdjuster()`

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:30

Inherits from: ToolExecutor

Member Variables

private llvm::Optional<CommonOptionsParser> OptionsParser
private clang::tooling::ClangTool Tool
private clang::tooling::ExecutionContext Context
private clang::tooling::InMemoryToolResults Results
private clang::tooling::ArgumentsAdjuster ArgsAdjuster
public static const char* ExecutorName

Method Overview

  • public StandaloneToolExecutor(const clang::tooling::CompilationDatabase & Compilations, llvm::ArrayRef<std::string> SourcePaths, IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS = llvm::vfs::getRealFileSystem(), std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<clang::PCHContainerOperations>())
  • public StandaloneToolExecutor(clang::tooling::CommonOptionsParser Options, std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<clang::PCHContainerOperations>())
  • public llvm::Error execute(llvm::ArrayRef<std::pair<std::unique_ptr<FrontendActionFactory>, ArgumentsAdjuster>> Actions)
  • public clang::tooling::ExecutionContext * getExecutionContext()
  • public llvm::StringRef getExecutorName() const
  • public clang::FileManager & getFiles()
  • public llvm::ArrayRef<std::string> getSourcePaths() const
  • public clang::tooling::ToolResults * getToolResults()
  • public void mapVirtualFile(llvm::StringRef FilePath, llvm::StringRef Content)
  • public void setDiagnosticConsumer(clang::DiagnosticConsumer * DiagConsumer)

Inherited from ToolExecutor:

Methods

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

Description

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

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:36

Parameters

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

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

Description

Init with \p CommonOptionsParser. This is expected to be used by `createExecutorFromCommandLineArgs` based on commandline options. The executor takes ownership of \p Options.

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:48

Parameters

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

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

Description

Executes each action with a corresponding arguments adjuster.

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:58

Parameters

llvm::ArrayRef<std::pair< std::unique_ptr<FrontendActionFactory>, ArgumentsAdjuster>> Actions

clang::tooling::ExecutionContext*
getExecutionContext()

Description

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

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:67

llvm::StringRef getExecutorName() const

Description

Returns the name of a specific executor.

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:53

clang::FileManager& getFiles()

Description

Returns the file manager used in the tool. The file manager is shared between all translation units.

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:82

llvm::ArrayRef<std::string> getSourcePaths() const

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:71

clang::tooling::ToolResults* getToolResults()

Description

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.

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:69

void mapVirtualFile(llvm::StringRef FilePath,
                    llvm::StringRef Content)

Description

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

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:75

Parameters

llvm::StringRef FilePath
The path at which the content will be mapped.
llvm::StringRef Content
A buffer of the file's content.

void setDiagnosticConsumer(
    clang::DiagnosticConsumer* DiagConsumer)

Description

Set a \c DiagnosticConsumer to use during parsing.

Declared at: clang/include/clang/Tooling/StandaloneExecution.h:63

Parameters

clang::DiagnosticConsumer* DiagConsumer