Home | History | Annotate | Download | only in Tooling

Lines Matching full:clang

1 //===--- Tooling.cpp - Running clang standalone tools ---------------------===//
10 // This file implements functions to run clang tools standalone instead
15 #include "clang/Tooling/Tooling.h"
16 #include "clang/AST/ASTConsumer.h"
17 #include "clang/Driver/Compilation.h"
18 #include "clang/Driver/Driver.h"
19 #include "clang/Driver/Tool.h"
20 #include "clang/Driver/ToolChain.h"
21 #include "clang/Frontend/ASTUnit.h"
22 #include "clang/Frontend/CompilerInstance.h"
23 #include "clang/Frontend/FrontendDiagnostic.h"
24 #include "clang/Frontend/TextDiagnosticPrinter.h"
25 #include "clang/Tooling/ArgumentsAdjusters.h"
26 #include "clang/Tooling/CompilationDatabase.h"
36 #define DEBUG_TYPE "clang-tooling"
38 namespace clang {
49 /// \brief Builds a clang driver initialized for running clang tools.
50 static clang::driver::Driver *newDriver(
51 clang::DiagnosticsEngine *Diagnostics, const char *BinaryName,
53 clang::driver::Driver *CompilerDriver =
54 new clang::driver::Driver(BinaryName, llvm::sys::getDefaultTargetTriple(),
60 /// \brief Retrieves the clang CC1 specific flags out of the compilation's jobs.
64 clang::DiagnosticsEngine *Diagnostics,
65 clang::driver::Compilation *Compilation) {
68 const clang::driver::JobList &Jobs = Compilation->getJobs();
69 if (Jobs.size() != 1 || !isa<clang::driver::Command>(*Jobs.begin())) {
73 Diagnostics->Report(clang::diag::err_fe_expected_compiler_job)
78 // The one job we find should be to invoke clang again.
79 const clang::driver::Command &Cmd =
80 cast<clang::driver::Command>(*Jobs.begin());
81 if (StringRef(Cmd.getCreator().getName()) != "clang") {
82 Diagnostics->Report(clang::diag::err_fe_expected_clang_command);
89 /// \brief Returns a clang build invocation initialized from the CC1 flags.
90 clang::CompilerInvocation *newInvocation(
91 clang::DiagnosticsEngine *Diagnostics,
94 clang::CompilerInvocation *Invocation = new clang::CompilerInvocation;
95 clang::CompilerInvocation::CreateFromArgs(
104 bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code,
108 FileName, "clang-tool",
125 clang::FrontendAction *ToolAction, const Twine &Code,
188 clang::driver::ToolChain::getTargetAndModeFromProgramName(InvokedAs);
246 IntrusiveRefCntPtr<clang::DiagnosticIDs>(new DiagnosticIDs()), &*DiagOpts,
249 const std::unique_ptr<clang::driver::Driver> Driver(
253 const std::unique_ptr<clang::driver::Compilation> Compilation(
260 std::unique_ptr<clang::CompilerInvocation> Invocation(
275 const char *BinaryName, clang::driver::Compilation *Compilation,
276 clang::CompilerInvocation *Invocation,
280 llvm::errs() << "clang Invocation:\n";
294 clang::CompilerInstance Compiler(std::move(PCHContainerOps));
432 // builtin headers in the resource dir need to match the exact clang
496 "clang-tool", std::move(PCHContainerOps));
530 } // end namespace clang