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;
72 runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
74 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
89 bool runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
91 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
107 template <
typename T>
139 template <
typename FactoryT>
153 const Twine &FileName =
"input.cc",
154 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
155 std::make_shared<PCHContainerOperations>());
176 const std::vector<std::string> &Args,
const Twine &FileName =
"input.cc",
177 const Twine &ToolName =
"clang-tool",
178 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
179 std::make_shared<PCHContainerOperations>(),
190 std::unique_ptr<ASTUnit>
192 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
193 std::make_shared<PCHContainerOperations>());
209 const Twine &Code,
const std::vector<std::string> &Args,
210 const Twine &FileName =
"input.cc",
const Twine &ToolName =
"clang-tool",
211 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
212 std::make_shared<PCHContainerOperations>(),
231 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
232 std::make_shared<PCHContainerOperations>());
241 ToolInvocation(std::vector<std::string> CommandLine, ToolAction *Action,
243 std::shared_ptr<PCHContainerOperations> PCHContainerOps);
249 this->DiagConsumer = DiagConsumer;
257 void mapVirtualFile(StringRef FilePath, StringRef Content);
267 bool runInvocation(
const char *BinaryName,
269 std::shared_ptr<clang::CompilerInvocation> Invocation,
270 std::shared_ptr<PCHContainerOperations> PCHContainerOps);
272 std::vector<std::string> CommandLine;
276 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
278 llvm::StringMap<StringRef> MappedFileContents;
301 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
302 std::make_shared<PCHContainerOperations>());
308 this->DiagConsumer = DiagConsumer;
315 void mapVirtualFile(StringRef FilePath, StringRef Content);
324 void clearArgumentsAdjusters();
329 int run(ToolAction *Action);
333 int buildASTs(std::vector<std::unique_ptr<ASTUnit>> &ASTs);
344 std::vector<std::string> SourcePaths;
345 std::shared_ptr<PCHContainerOperations> PCHContainerOps;
351 std::vector< std::pair<StringRef, StringRef> > MappedFileContents;
352 llvm::StringSet<> SeenWorkingDirectories;
359 template <
typename T>
366 return std::unique_ptr<FrontendActionFactory>(
367 new SimpleFrontendActionFactory);
370 template <
typename FactoryT>
375 explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory,
377 : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
380 return new ConsumerFactoryAdaptor(ConsumerFactory, Callbacks);
386 ConsumerFactoryAdaptor(FactoryT *ConsumerFactory,
388 : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
390 std::unique_ptr<clang::ASTConsumer>
392 return ConsumerFactory->newASTConsumer();
403 void EndSourceFileAction()
override {
410 FactoryT *ConsumerFactory;
413 FactoryT *ConsumerFactory;
417 return std::unique_ptr<FrontendActionFactory>(
418 new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks));
456 StringRef InvokedAs);
461 const llvm::opt::ArgStringList &CC1Args);
466 #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.
Defines the Diagnostic-related interfaces.
const FunctionProtoType * T
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.
Dataflow Directional Tag Classes.
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.
Compilation - A set of tasks to perform for a single driver invocation.
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
This class handles loading and caching of source files into memory.