[clang] [clang-repl] Drop CodeGen module when an input has parse errors (PR #169989)

Anutosh Bhat via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 29 04:16:30 PST 2025


================
@@ -120,6 +120,17 @@ std::unique_ptr<llvm::Module> IncrementalAction::GenModule() {
   return nullptr;
 }
 
+void IncrementalAction::discardCurrentCodeGenModule() {
+  if (CodeGenerator *CG = getCodeGen()) {
+    if (auto *CurM = CG->GetModule()) {
+      llvm::LLVMContext &Ctx = CurM->getContext();
+      std::string Name = CurM->getName().str();
+      std::unique_ptr<llvm::Module> Dead(CG->ReleaseModule());
+      CG->StartModule(Name, Ctx);
+    }
----------------
anutosh491 wrote:

Used the variable name Dead for now ! Can you use Discarded or something along those lines I think



https://github.com/llvm/llvm-project/pull/169989


More information about the cfe-commits mailing list