class ToolInvocation

Declaration

class ToolInvocation { /* full declaration omitted */ };

Description

Utility to run a FrontendAction in a single clang invocation.

Declared at: clang/include/clang/Tooling/Tooling.h:239

Member Variables

private std::vector<std::string> CommandLine
private clang::tooling::ToolAction* Action
private bool OwnsAction
private clang::FileManager* Files
private std::shared_ptr<PCHContainerOperations> PCHContainerOps
private clang::DiagnosticConsumer* DiagConsumer = nullptr
private clang::DiagnosticOptions* DiagOpts = nullptr

Method Overview

  • public ToolInvocation(std::vector<std::string> CommandLine, std::unique_ptr<FrontendAction> FAction, clang::FileManager * Files, std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<clang::PCHContainerOperations>())
  • public ToolInvocation(std::vector<std::string> CommandLine, clang::tooling::ToolAction * Action, clang::FileManager * Files, std::shared_ptr<PCHContainerOperations> PCHContainerOps)
  • public bool run()
  • private bool runInvocation(const char * BinaryName, driver::Compilation * Compilation, std::shared_ptr<CompilerInvocation> Invocation, std::shared_ptr<PCHContainerOperations> PCHContainerOps)
  • public void setDiagnosticConsumer(clang::DiagnosticConsumer * DiagConsumer)
  • public void setDiagnosticOptions(clang::DiagnosticOptions * DiagOpts)
  • public ~ToolInvocation()

Methods

ToolInvocation(
    std::vector<std::string> CommandLine,
    std::unique_ptr<FrontendAction> FAction,
    clang::FileManager* Files,
    std::shared_ptr<PCHContainerOperations>
        PCHContainerOps = std::make_shared<
            clang::PCHContainerOperations>())

Description

Create a tool invocation.

Declared at: clang/include/clang/Tooling/Tooling.h:252

Parameters

std::vector<std::string> CommandLine
The command line arguments to clang. Note that clang uses its binary name (CommandLine[0]) to locate its builtin headers. Callers have to ensure that they are installed in a compatible location (see clang driver implementation) or mapped in via mapVirtualFile.
std::unique_ptr<FrontendAction> FAction
The action to be executed.
clang::FileManager* Files
The FileManager used for the execution. Class does not take ownership.
std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<clang::PCHContainerOperations>()
The PCHContainerOperations for loading and creating clang modules.

ToolInvocation(
    std::vector<std::string> CommandLine,
    clang::tooling::ToolAction* Action,
    clang::FileManager* Files,
    std::shared_ptr<PCHContainerOperations>
        PCHContainerOps)

Description

Create a tool invocation.

Declared at: clang/include/clang/Tooling/Tooling.h:264

Parameters

std::vector<std::string> CommandLine
The command line arguments to clang.
clang::tooling::ToolAction* Action
The action to be executed.
clang::FileManager* Files
The FileManager used for the execution.
std::shared_ptr<PCHContainerOperations> PCHContainerOps
The PCHContainerOperations for loading and creating clang modules.

bool run()

Description

Run the clang invocation.

Declared at: clang/include/clang/Tooling/Tooling.h:284

Returns

True if there were no errors during execution.

bool runInvocation(
    const char* BinaryName,
    driver::Compilation* Compilation,
    std::shared_ptr<CompilerInvocation>
        Invocation,
    std::shared_ptr<PCHContainerOperations>
        PCHContainerOps)

Declared at: clang/include/clang/Tooling/Tooling.h:287

Parameters

const char* BinaryName
driver::Compilation* Compilation
std::shared_ptr<CompilerInvocation> Invocation
std::shared_ptr<PCHContainerOperations> PCHContainerOps

void setDiagnosticConsumer(
    clang::DiagnosticConsumer* DiagConsumer)

Description

Set a \c DiagnosticConsumer to use during driver command-line parsing and the action invocation itself.

Declared at: clang/include/clang/Tooling/Tooling.h:272

Parameters

clang::DiagnosticConsumer* DiagConsumer

void setDiagnosticOptions(
    clang::DiagnosticOptions* DiagOpts)

Description

Set a \c DiagnosticOptions to use during driver command-line parsing.

Declared at: clang/include/clang/Tooling/Tooling.h:277

Parameters

clang::DiagnosticOptions* DiagOpts

~ToolInvocation()

Declared at: clang/include/clang/Tooling/Tooling.h:268