[clang] [clang-repl] Drop the IR of a failed input (PR #226285)

Jared Wyles via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 21 00:43:58 PST 2026


================
@@ -1062,8 +1062,25 @@ void CodeGenModule::checkAliases() {
 
 void CodeGenModule::clear() {
   DeferredDeclsToEmit.clear();
+  if (Context.getLangOpts().IncrementalExtensions) {
+    // The next input starts a new module. It can still emit the deferred decls
+    // of the earlier inputs, but not those of the failed unit.
+    DeferredDecls.insert_range(EmittedDeferredDecls);
+    const TranslationUnitDecl *TU = Context.getTranslationUnitDecl();
+    auto InFailedUnit = [TU](const Decl *D) {
+      return D->getTranslationUnitDecl() == TU;
+    };
+    SmallVector<StringRef, 8> Dropped;
----------------
jaredwy wrote:

Is smallvector the best choice here? It seems like this will pretty commonly have to reallocate? Couldn't we get the size of the failed units, thena llocate a vector once? 

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


More information about the cfe-commits mailing list