diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-04 19:20:19 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-08 19:02:26 +0000 |
commit | 81ad626541db97eb356e2c1d4a20eb2a26a766ab (patch) | |
tree | 311b6a8987c32b1e1dcbab65c54cfac3fdb56175 /contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp | |
parent | 5fff09660e06a66bed6482da9c70df328e16bbb6 (diff) | |
parent | 145449b1e420787bb99721a429341fa6be3adfb6 (diff) |
Diffstat (limited to 'contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp b/contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp index 470c9c289a74..0191ad78581d 100644 --- a/contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp +++ b/contrib/llvm-project/clang/lib/Interpreter/Interpreter.cpp @@ -116,6 +116,9 @@ CreateCI(const llvm::opt::ArgStringList &Argv) { // times, reusing the same AST. Clang->getCodeGenOpts().ClearASTBeforeBackend = false; + Clang->getFrontendOpts().DisableFree = false; + Clang->getCodeGenOpts().DisableFree = false; + return std::move(Clang); } @@ -210,16 +213,16 @@ Interpreter::Parse(llvm::StringRef Code) { llvm::Error Interpreter::Execute(PartialTranslationUnit &T) { assert(T.TheModule); if (!IncrExecutor) { - const llvm::Triple &Triple = - getCompilerInstance()->getASTContext().getTargetInfo().getTriple(); + const clang::TargetInfo &TI = + getCompilerInstance()->getASTContext().getTargetInfo(); llvm::Error Err = llvm::Error::success(); - IncrExecutor = std::make_unique<IncrementalExecutor>(*TSCtx, Err, Triple); + IncrExecutor = std::make_unique<IncrementalExecutor>(*TSCtx, Err, TI); if (Err) return Err; } // FIXME: Add a callback to retain the llvm::Module once the JIT is done. - if (auto Err = IncrExecutor->addModule(std::move(T.TheModule))) + if (auto Err = IncrExecutor->addModule(T)) return Err; if (auto Err = IncrExecutor->runCtors()) @@ -257,3 +260,22 @@ Interpreter::getSymbolAddressFromLinkerName(llvm::StringRef Name) const { return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName); } + +llvm::Error Interpreter::Undo(unsigned N) { + + std::list<PartialTranslationUnit> &PTUs = IncrParser->getPTUs(); + if (N > PTUs.size()) + return llvm::make_error<llvm::StringError>("Operation failed. " + "Too many undos", + std::error_code()); + for (unsigned I = 0; I < N; I++) { + if (IncrExecutor) { + if (llvm::Error Err = IncrExecutor->removeModule(PTUs.back())) + return Err; + } + + IncrParser->CleanUpPTU(PTUs.back()); + PTUs.pop_back(); + } + return llvm::Error::success(); +} |