30 #ifndef LLVM_CLANG_TOOLING_TOOLING_H
31 #define LLVM_CLANG_TOOLING_TOOLING_H
43 #include "llvm/ADT/StringMap.h"
44 #include "llvm/ADT/Twine.h"
45 #include "llvm/Option/Option.h"
56 class CompilerInvocation;
73 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
89 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
105 template <
typename T>
137 template <
typename FactoryT>
139 FactoryT *ConsumerFactory, SourceFileCallbacks *Callbacks =
nullptr);
151 const Twine &FileName =
"input.cc",
152 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
153 std::make_shared<PCHContainerOperations>());
172 const std::vector<std::string> &Args,
const Twine &FileName =
"input.cc",
173 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
174 std::make_shared<PCHContainerOperations>(),
185 std::unique_ptr<ASTUnit>
187 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
188 std::make_shared<PCHContainerOperations>());
200 const Twine &Code,
const std::vector<std::string> &Args,
201 const Twine &FileName =
"input.cc",
202 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
203 std::make_shared<PCHContainerOperations>());
221 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
222 std::make_shared<PCHContainerOperations>());
231 ToolInvocation(std::vector<std::string> CommandLine, ToolAction *Action,
233 std::shared_ptr<PCHContainerOperations> PCHContainerOps);
239 this->DiagConsumer = DiagConsumer;
257 bool runInvocation(
const char *BinaryName,
260 std::shared_ptr<PCHContainerOperations> PCHContainerOps);
262 std::vector<std::string> CommandLine;
266 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
268 llvm::StringMap<StringRef> MappedFileContents;
291 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
292 std::make_shared<PCHContainerOperations>());
298 this->DiagConsumer = DiagConsumer;
332 std::vector<std::string> SourcePaths;
333 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
339 std::vector< std::pair<StringRef, StringRef> > MappedFileContents;
340 llvm::StringSet<> SeenWorkingDirectories;
347 template <
typename T>
354 return std::unique_ptr<FrontendActionFactory>(
355 new SimpleFrontendActionFactory);
358 template <
typename FactoryT>
363 explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory,
365 : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
368 return new ConsumerFactoryAdaptor(ConsumerFactory, Callbacks);
374 ConsumerFactoryAdaptor(FactoryT *ConsumerFactory,
376 : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
378 std::unique_ptr<clang::ASTConsumer>
380 return ConsumerFactory->newASTConsumer();
392 void EndSourceFileAction()
override {
399 FactoryT *ConsumerFactory;
402 FactoryT *ConsumerFactory;
406 return std::unique_ptr<FrontendActionFactory>(
407 new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks));
445 StringRef InvokedAs);
450 const llvm::opt::ArgStringList &CC1Args);
455 #endif // LLVM_CLANG_TOOLING_TOOLING_H
Implements support for file system lookup, file system caching, and directory search management...
Defines the clang::FileManager interface and associated types.
Abstract base class for actions which can be performed by the frontend.
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Concrete class used by the front-end to report problems and issues.
virtual bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename)
Callback at the start of processing a single input.
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Abstract base class to use for AST consumer-based frontend actions.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
Helper class for holding the data necessary to invoke the compiler.
std::vector< std::string > CommandLine
Defines the Diagnostic-related interfaces.
Compilation - A set of tasks to perform for a single driver invocation.
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
This class handles loading and caching of source files into memory.