aboutsummaryrefslogtreecommitdiff
path: root/clang/include/clang/Interpreter/Interpreter.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include/clang/Interpreter/Interpreter.h')
-rw-r--r--clang/include/clang/Interpreter/Interpreter.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h
new file mode 100644
index 000000000000..020cbe2db3d0
--- /dev/null
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -0,0 +1,71 @@
+//===--- Interpreter.h - Incremental Compilation and Execution---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the component which performs incremental code
+// compilation and execution.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
+#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
+
+#include "clang/Interpreter/PartialTranslationUnit.h"
+
+#include "llvm/Support/Error.h"
+
+#include <memory>
+#include <vector>
+
+namespace llvm {
+namespace orc {
+class ThreadSafeContext;
+}
+class Module;
+} // namespace llvm
+
+namespace clang {
+
+class CompilerInstance;
+class DeclGroupRef;
+class IncrementalExecutor;
+class IncrementalParser;
+
+/// Create a pre-configured \c CompilerInstance for incremental processing.
+class IncrementalCompilerBuilder {
+public:
+ static llvm::Expected<std::unique_ptr<CompilerInstance>>
+ create(std::vector<const char *> &ClangArgv);
+};
+
+/// Provides top-level interfaces for incremental compilation and execution.
+class Interpreter {
+ std::unique_ptr<llvm::orc::ThreadSafeContext> TSCtx;
+ std::unique_ptr<IncrementalParser> IncrParser;
+ std::unique_ptr<IncrementalExecutor> IncrExecutor;
+
+ Interpreter(std::unique_ptr<CompilerInstance> CI, llvm::Error &Err);
+
+public:
+ ~Interpreter();
+ static llvm::Expected<std::unique_ptr<Interpreter>>
+ create(std::unique_ptr<CompilerInstance> CI);
+ const CompilerInstance *getCompilerInstance() const;
+ llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code);
+ llvm::Error Execute(PartialTranslationUnit &T);
+ llvm::Error ParseAndExecute(llvm::StringRef Code) {
+ auto PTU = Parse(Code);
+ if (!PTU)
+ return PTU.takeError();
+ if (PTU->TheModule)
+ return Execute(*PTU);
+ return llvm::Error::success();
+ }
+};
+} // namespace clang
+
+#endif // LLVM_CLANG_INTERPRETER_INTERPRETER_H