[clang] [clang-repl] Skip CodeGen for top-level decls when diagnostics report errors (PR #169989)
Anutosh Bhat via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 8 04:48:34 PST 2025
anutosh491 wrote:
My first approach here https://github.com/llvm/llvm-project/pull/169989#issuecomment-3591621666 highlights how I thought dropping the faulty module having the IR leaked from the input line above was the solution. This is what [commit1](https://github.com/llvm/llvm-project/pull/169989/commits/a6c9ac10aca449bee2fdebd8e0ec9fe7d363d0ad) was trying to do.
But on discussing with @vgvassilev , we discovered that we're making a call to codegen even when an error has occured.
So basically we don’t want failing inputs to produce IR or leak state into subsequent cells. This patch adds a guard in `InProcessPrintingASTConsumer::HandleTopLevelDecl` that returns early when `DiagnosticsEngine::hasErrorOccurred()` is `true`, so the `MultiplexConsumer/CodeGen` path is not invoked for erroneous inputs.
https://github.com/llvm/llvm-project/pull/169989
More information about the cfe-commits
mailing list