clang 8.0.0

Public Member Functions | List of all members
clang::tooling::ToolInvocation Class Reference

Utility to run a FrontendAction in a single clang invocation. More...

`#include "clang/Tooling/Tooling.h"`

## Public Member Functions
| ToolInvocation (std::vector< std::string > CommandLine, FrontendAction *FAction, FileManager *Files, std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
| Create a tool invocation. More...
| ToolInvocation (std::vector< std::string > CommandLine, ToolAction *Action, FileManager *Files, std::shared_ptr< PCHContainerOperations > PCHContainerOps)
| Create a tool invocation. More...
| ~ToolInvocation ()
void | setDiagnosticConsumer (DiagnosticConsumer *DiagConsumer)
| Set a `DiagnosticConsumer` to use during parsing. More...
void | mapVirtualFile (StringRef FilePath, StringRef Content)
| Map a virtual file to be used while running the tool. More...
bool | run ()
| Run the clang invocation. More...

## Detailed Description

Utility to run a FrontendAction in a single clang invocation.

Definition at line 233 of file Tooling.h.

## Constructor & Destructor Documentation

## ◆ ToolInvocation() [1/2]

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

Create a tool invocation.

Parameters

  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.
  FAction | The action to be executed. Class takes ownership.
  Files | The FileManager used for the execution. Class does not take ownership.
  PCHContainerOps | The PCHContainerOperations for loading and creating clang modules.

Definition at line 269 of file Tooling.cpp.

## ◆ ToolInvocation() [2/2]

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

Create a tool invocation.

Parameters

  CommandLine | The command line arguments to clang.
  Action | The action to be executed.
  Files | The FileManager used for the execution.
  PCHContainerOps | The PCHContainerOperations for loading and creating clang modules.

Definition at line 263 of file Tooling.cpp.

## ◆ ~ToolInvocation()

ToolInvocation::~ToolInvocation | ( |  | ) |

Definition at line 276 of file Tooling.cpp.

## Member Function Documentation

## ◆ mapVirtualFile()

void ToolInvocation::mapVirtualFile | ( | StringRef | FilePath,
|  | StringRef | Content
| ) |  |

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

Parameters

  FilePath | The path at which the content will be mapped.
  Content | A null terminated buffer of the file's content.

Definition at line 281 of file Tooling.cpp.

## ◆ run()

bool ToolInvocation::run | ( |  | ) |

Run the clang invocation.

Returns
  True if there were no errors during execution.

Definition at line 287 of file Tooling.cpp.

References clang::driver::createDriverOptTable(), getCC1Arguments(), clang::FileManager::getFileSystemOpts(), clang::driver::Compilation::getJobs(), clang::FileManager::getVirtualFileSystem(), newDriver(), clang::tooling::newInvocation(), clang::ParseDiagnosticArgs(), clang::driver::JobList::Print(), clang::tooling::ToolAction::runInvocation(), and clang::FileSystemOptions::WorkingDir.

Referenced by clang::tooling::runToolOnCodeWithArgs().

## ◆ setDiagnosticConsumer()

void clang::tooling::ToolInvocation::setDiagnosticConsumer | ( | DiagnosticConsumer * | DiagConsumer | ) |
| inline

Set a `DiagnosticConsumer` to use during parsing.

Definition at line 265 of file Tooling.h.

Referenced by clang::tooling::ClangTool::run().

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

- include/clang/Tooling/Tooling.h
- lib/Tooling/Tooling.cpp