clang 10.0.0git

Namespaces | Macros | Functions
Tooling.cpp File Reference
`#include "clang/Tooling/Tooling.h"`
`#include "clang/Basic/Diagnostic.h"`
`#include "clang/Basic/DiagnosticIDs.h"`
`#include "clang/Basic/DiagnosticOptions.h"`
`#include "clang/Basic/FileManager.h"`
`#include "clang/Basic/FileSystemOptions.h"`
`#include "clang/Basic/LLVM.h"`
`#include "clang/Driver/Compilation.h"`
`#include "clang/Driver/Driver.h"`
`#include "clang/Driver/Job.h"`
`#include "clang/Driver/Options.h"`
`#include "clang/Driver/Tool.h"`
`#include "clang/Driver/ToolChain.h"`
`#include "clang/Frontend/ASTUnit.h"`
`#include "clang/Frontend/CompilerInstance.h"`
`#include "clang/Frontend/CompilerInvocation.h"`
`#include "clang/Frontend/FrontendDiagnostic.h"`
`#include "clang/Frontend/FrontendOptions.h"`
`#include "clang/Frontend/TextDiagnosticPrinter.h"`
`#include "clang/Lex/HeaderSearchOptions.h"`
`#include "clang/Lex/PreprocessorOptions.h"`
`#include "clang/Tooling/ArgumentsAdjusters.h"`
`#include "clang/Tooling/CompilationDatabase.h"`
`#include "llvm/ADT/ArrayRef.h"`
`#include "llvm/ADT/IntrusiveRefCntPtr.h"`
`#include "llvm/ADT/SmallString.h"`
`#include "llvm/ADT/StringRef.h"`
`#include "llvm/ADT/Twine.h"`
`#include "llvm/Option/ArgList.h"`
`#include "llvm/Option/OptTable.h"`
`#include "llvm/Option/Option.h"`
`#include "llvm/Support/Casting.h"`
`#include "llvm/Support/Debug.h"`
`#include "llvm/Support/ErrorHandling.h"`
`#include "llvm/Support/FileSystem.h"`
`#include "llvm/Support/Host.h"`
`#include "llvm/Support/MemoryBuffer.h"`
`#include "llvm/Support/Path.h"`
`#include "llvm/Support/VirtualFileSystem.h"`
`#include "llvm/Support/raw_ostream.h"`
`#include <cassert>`
`#include <cstring>`
`#include <memory>`
`#include <string>`
`#include <system_error>`
`#include <utility>`
`#include <vector>`
Include dependency graph for Tooling.cpp:

Go to the source code of this file.

## Namespaces
| clang
| Dataflow Directional Tag Classes.
| clang::tooling

## Macros
#define | DEBUG_TYPE "clang-tooling"

## Functions
static driver::Driver * | newDriver (DiagnosticsEngine *Diagnostics, const char *BinaryName, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS)
| Builds a clang driver initialized for running clang tools. More...
static const llvm::opt::ArgStringList * | getCC1Arguments (DiagnosticsEngine *Diagnostics, driver::Compilation *Compilation)
| Retrieves the clang CC1 specific flags out of the compilation's jobs. More...
CompilerInvocation * | clang::tooling::newInvocation (DiagnosticsEngine *Diagnostics, const llvm::opt::ArgStringList &CC1Args)
| Creates a `CompilerInvocation`. More...
bool | clang::tooling::runToolOnCode (std::unique_ptr< FrontendAction > ToolAction, const Twine &Code, const Twine &FileName="input.cc", std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
| Runs (and deletes) the tool on 'Code' with the -fsyntax-only flag. More...
static std::vector< std::string > | getSyntaxOnlyToolArgs (const Twine &ToolName, const std::vector< std::string > &ExtraArgs, StringRef FileName)
bool | clang::tooling::runToolOnCodeWithArgs (std::unique_ptr< FrontendAction > ToolAction, const Twine &Code, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, const std::vector< std::string > &Args, const Twine &FileName="input.cc", const Twine &ToolName="clang-tool", std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
bool | clang::tooling::runToolOnCodeWithArgs (std::unique_ptr< FrontendAction > ToolAction, const Twine &Code, const std::vector< std::string > &Args, const Twine &FileName="input.cc", const Twine &ToolName="clang-tool", std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >(), const FileContentMappings &VirtualMappedFiles=FileContentMappings())
| Runs (and deletes) the tool on 'Code' with the -fsyntax-only flag and with additional other flags. More...
llvm::Expected< std::string > | clang::tooling::getAbsolutePath (llvm::vfs::FileSystem &FS, StringRef File)
| An overload of getAbsolutePath that works over the provided `FS`. More...
std::string | clang::tooling::getAbsolutePath (StringRef File)
| Returns the absolute path of `File`, by prepending it with the current directory if `File` is not absolute. More...
void | clang::tooling::addTargetAndModeForProgramName (std::vector< std::string > &CommandLine, StringRef InvokedAs)
| Changes CommandLine to contain implicit flags that would have been defined had the compiler driver been invoked through the path InvokedAs. More...
static void | injectResourceDir (CommandLineArguments &Args, const char *Argv0, void *MainAddr)
std::unique_ptr< ASTUnit > | clang::tooling::buildASTFromCode (StringRef Code, StringRef FileName="input.cc", std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >())
| Builds an AST for 'Code'. More...
std::unique_ptr< ASTUnit > | clang::tooling::buildASTFromCodeWithArgs (StringRef Code, const std::vector< std::string > &Args, StringRef FileName="input.cc", StringRef ToolName="clang-tool", std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >(), ArgumentsAdjuster Adjuster=getClangStripDependencyFileAdjuster(), const FileContentMappings &VirtualMappedFiles=FileContentMappings())
| Builds an AST for 'Code' with additional flags. More...

## Macro Definition Documentation

## ◆ DEBUG_TYPE

#define DEBUG_TYPE "clang-tooling"

Definition at line 62 of file Tooling.cpp.

## Function Documentation

## ◆ getCC1Arguments()

static const llvm::opt::ArgStringList* getCC1Arguments | ( | DiagnosticsEngine * | Diagnostics,
|  | driver::Compilation * | Compilation
| ) |  |
| static

Retrieves the clang CC1 specific flags out of the compilation's jobs.

Returns nullptr on error.

Definition at line 89 of file Tooling.cpp.

References clang::driver::JobList::begin(), Cmd, clang::driver::Compilation::getActions(), clang::driver::Compilation::getJobs(), clang::driver::JobList::Print(), clang::DiagnosticsEngine::Report(), and clang::driver::JobList::size().

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

## ◆ getSyntaxOnlyToolArgs()

static std::vector<std::string> getSyntaxOnlyToolArgs | ( | const Twine & | ToolName,
|  | const std::vector< std::string > & | ExtraArgs,
|  | StringRef | FileName
| ) |  |
| static

Definition at line 166 of file Tooling.cpp.

Referenced by clang::tooling::buildASTFromCodeWithArgs(), and clang::tooling::runToolOnCodeWithArgs().

## ◆ injectResourceDir()

static void injectResourceDir | ( | CommandLineArguments & | Args,
|  | const char * | Argv0,
|  | void * | MainAddr
| ) |  |
| static

Definition at line 436 of file Tooling.cpp.

References clang::CompilerInvocation::GetResourcesPath().

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

## ◆ newDriver()

static driver::Driver* newDriver | ( | DiagnosticsEngine * | Diagnostics,
|  | const char * | BinaryName,
|  | IntrusiveRefCntPtr< llvm::vfs::FileSystem > | VFS
| ) |  |
| static

Builds a clang driver initialized for running clang tools.

Definition at line 77 of file Tooling.cpp.

References clang::driver::Driver::setTitle().

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