File indexing completed on 2026-05-10 08:37:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_TOOLING_STANDALONEEXECUTION_H
0014 #define LLVM_CLANG_TOOLING_STANDALONEEXECUTION_H
0015
0016 #include "clang/Tooling/ArgumentsAdjusters.h"
0017 #include "clang/Tooling/Execution.h"
0018 #include <optional>
0019
0020 namespace clang {
0021 namespace tooling {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class StandaloneToolExecutor : public ToolExecutor {
0032 public:
0033 static const char *ExecutorName;
0034
0035
0036
0037 StandaloneToolExecutor(
0038 const CompilationDatabase &Compilations,
0039 llvm::ArrayRef<std::string> SourcePaths,
0040 IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS =
0041 llvm::vfs::getRealFileSystem(),
0042 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
0043 std::make_shared<PCHContainerOperations>());
0044
0045
0046
0047
0048
0049 StandaloneToolExecutor(
0050 CommonOptionsParser Options,
0051 std::shared_ptr<PCHContainerOperations> PCHContainerOps =
0052 std::make_shared<PCHContainerOperations>());
0053
0054 StringRef getExecutorName() const override { return ExecutorName; }
0055
0056 using ToolExecutor::execute;
0057
0058 llvm::Error
0059 execute(llvm::ArrayRef<
0060 std::pair<std::unique_ptr<FrontendActionFactory>, ArgumentsAdjuster>>
0061 Actions) override;
0062
0063
0064 void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
0065 Tool.setDiagnosticConsumer(DiagConsumer);
0066 }
0067
0068 ExecutionContext *getExecutionContext() override { return &Context; };
0069
0070 ToolResults *getToolResults() override { return &Results; }
0071
0072 llvm::ArrayRef<std::string> getSourcePaths() const {
0073 return Tool.getSourcePaths();
0074 }
0075
0076 void mapVirtualFile(StringRef FilePath, StringRef Content) override {
0077 Tool.mapVirtualFile(FilePath, Content);
0078 }
0079
0080
0081
0082
0083 FileManager &getFiles() { return Tool.getFiles(); }
0084
0085 private:
0086
0087 std::optional<CommonOptionsParser> OptionsParser;
0088
0089
0090 ClangTool Tool;
0091 ExecutionContext Context;
0092 InMemoryToolResults Results;
0093 ArgumentsAdjuster ArgsAdjuster;
0094 };
0095
0096 }
0097 }
0098
0099 #endif