[clang] [clang-repl] Unlink the withdrawn partial translation unit on Undo (PR #213235)

Emery Conrad via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 31 05:49:20 PDT 2026


conrade-ctc wrote:

@vgvassilev thanks — moved it into `IncrementalParser::withdrawMostRecentTU`, so there are no AST changes left at all. `Redeclarable` and `ASTContext` already declare `friend class IncrementalParser`, so both the chain rebuild and the `TUDecl`/`TraversalScope` fixup stay in the interpreter.

I only handle the remove-the-latest case rather than porting all of cling's `removeRedeclFromChain`: `CleanUpPTU` is only ever called with the current TU (now asserted), since `Undo` is strictly LIFO. Happy to generalise if you would rather have the whole helper.

One thing I would still like your read on: `CleanUpPTU` also runs on the parse-failure path, so a failed input now unlinks its unit too. That seemed right to me, but say the word if you would rather scope it to `Undo` only.


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


More information about the cfe-commits mailing list