clang
3.9.0
|
Utility to run a FrontendAction over a set of files. More...
#include <Tooling.h>
Public Member Functions | |
ClangTool (const CompilationDatabase &Compilations, ArrayRef< std::string > SourcePaths, std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >()) | |
Constructs a clang tool to run over a list of files. More... | |
~ClangTool () | |
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... | |
void | appendArgumentsAdjuster (ArgumentsAdjuster Adjuster) |
Append a command line arguments adjuster to the adjuster chain. More... | |
void | clearArgumentsAdjusters () |
Clear the command line arguments adjuster chain. More... | |
int | run (ToolAction *Action) |
Runs an action over all files specified in the command line. More... | |
int | buildASTs (std::vector< std::unique_ptr< ASTUnit >> &ASTs) |
Create an AST for each file specified in the command line and append them to ASTs. More... | |
FileManager & | getFiles () |
Returns the file manager used in the tool. More... | |
Utility to run a FrontendAction over a set of files.
This class is written to be usable for command line utilities. By default the class uses ClangSyntaxOnlyAdjuster to modify command line arguments before the arguments are used to run a frontend action. One could install an additional command line arguments adjuster by calling the appendArgumentsAdjuster() method.
clang::tooling::ClangTool::ClangTool | ( | const CompilationDatabase & | Compilations, |
ArrayRef< std::string > | SourcePaths, | ||
std::shared_ptr< PCHContainerOperations > | PCHContainerOps = std::make_shared<PCHContainerOperations>() |
||
) |
Constructs a clang tool to run over a list of files.
Compilations | The CompilationDatabase which contains the compile command lines for the given source paths. |
SourcePaths | The source files to run over. If a source files is not found in Compilations, it is skipped. |
PCHContainerOps | The PCHContainerOperations for loading and creating clang modules. |
Definition at line 316 of file Tooling.cpp.
References appendArgumentsAdjuster(), clang::tooling::getClangStripOutputAdjuster(), and clang::tooling::getClangSyntaxOnlyAdjuster().
clang::tooling::ClangTool::~ClangTool | ( | ) |
Definition at line 330 of file Tooling.cpp.
void clang::tooling::ClangTool::appendArgumentsAdjuster | ( | ArgumentsAdjuster | Adjuster | ) |
Append a command line arguments adjuster to the adjuster chain.
Adjuster | An argument adjuster, which will be run on the output of previous argument adjusters. |
Definition at line 336 of file Tooling.cpp.
References clang::tooling::combineAdjusters().
Referenced by ClangTool().
int clang::tooling::ClangTool::buildASTs | ( | std::vector< std::unique_ptr< ASTUnit >> & | ASTs | ) |
Create an AST for each file specified in the command line and append them to ASTs.
Definition at line 487 of file Tooling.cpp.
void clang::tooling::ClangTool::clearArgumentsAdjusters | ( | ) |
Clear the command line arguments adjuster chain.
Definition at line 344 of file Tooling.cpp.
|
inline |
Returns the file manager used in the tool.
The file manager is shared between all translation units.
Definition at line 333 of file Tooling.h.
Referenced by clang::tooling::RefactoringTool::runAndSave().
void clang::tooling::ClangTool::mapVirtualFile | ( | StringRef | FilePath, |
StringRef | Content | ||
) |
Map a virtual file to be used while running the tool.
FilePath | The path at which the content will be mapped. |
Content | A null terminated buffer of the file's content. |
Definition at line 332 of file Tooling.cpp.
int clang::tooling::ClangTool::run | ( | ToolAction * | Action | ) |
Runs an action over all files specified in the command line.
Action | Tool action. |
Definition at line 360 of file Tooling.cpp.
References clang::tooling::CompileCommand::CommandLine, CommandLine, clang::tooling::CompileCommand::Directory, clang::tooling::CompileCommand::Filename, clang::tooling::getAbsolutePath(), clang::tooling::CompilationDatabase::getCompileCommands(), and clang::tooling::injectResourceDir().
Referenced by buildASTs(), and clang::tooling::RefactoringTool::runAndSave().
|
inline |
Set a DiagnosticConsumer
to use during parsing.