[clang] [CIR] Don't generate ClangIR after an unrecoverable error occured (PR #130971)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 07:42:05 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Morris Hafner (mmha)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/130971.diff


1 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenerator.cpp (+2) 


``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index 91070eda7d45a..6fa31ab707139 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -43,6 +43,8 @@ void CIRGenerator::Initialize(ASTContext &astContext) {
 mlir::ModuleOp CIRGenerator::getModule() const { return cgm->getModule(); }
 
 bool CIRGenerator::HandleTopLevelDecl(DeclGroupRef group) {
+  if (diags.hasUnrecoverableErrorOccurred())
+    return true;
 
   for (Decl *decl : group)
     cgm->emitTopLevelDecl(decl);

``````````

</details>


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


More information about the cfe-commits mailing list