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);
152 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
153 std::make_shared<PCHContainerOperations>());
174 const std::vector<std::string> &Args,
const Twine &
FileName =
"input.cc",
175 const Twine &ToolName =
"clang-tool",
176 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
177 std::make_shared<PCHContainerOperations>(),
188 std::unique_ptr<ASTUnit>
190 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
191 std::make_shared<PCHContainerOperations>());
205 const Twine &Code,
const std::vector<std::string> &Args,
206 const Twine &
FileName =
"input.cc",
const Twine &ToolName =
"clang-tool",
207 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
208 std::make_shared<PCHContainerOperations>());
226 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
227 std::make_shared<PCHContainerOperations>());
236 ToolInvocation(std::vector<std::string> CommandLine, ToolAction *Action,
238 std::shared_ptr<PCHContainerOperations> PCHContainerOps);
244 this->DiagConsumer = DiagConsumer;
262 bool runInvocation(
const char *BinaryName,
265 std::shared_ptr<PCHContainerOperations> PCHContainerOps);
267 std::vector<std::string> CommandLine;
271 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
273 llvm::StringMap<StringRef> MappedFileContents;
296 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
297 std::make_shared<PCHContainerOperations>());
303 this->DiagConsumer = DiagConsumer;
337 std::vector<std::string> SourcePaths;
338 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
344 std::vector< std::pair<StringRef, StringRef> > MappedFileContents;
345 llvm::StringSet<> SeenWorkingDirectories;
352 template <
typename T>
359 return std::unique_ptr<FrontendActionFactory>(
360 new SimpleFrontendActionFactory);
363 template <
typename FactoryT>
368 explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory,
370 : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
373 return new ConsumerFactoryAdaptor(ConsumerFactory, Callbacks);
379 ConsumerFactoryAdaptor(FactoryT *ConsumerFactory,
381 : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
383 std::unique_ptr<clang::ASTConsumer>
385 return ConsumerFactory->newASTConsumer();
397 void EndSourceFileAction()
override {
404 FactoryT *ConsumerFactory;
407 FactoryT *ConsumerFactory;
411 return std::unique_ptr<FrontendActionFactory>(
412 new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks));
450 StringRef InvokedAs);
455 const llvm::opt::ArgStringList &CC1Args);
460 #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.