[clang] [CIR] Defer definitions of global variables until they are used. (PR #142496)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 2 15:49:25 PDT 2025


================
@@ -63,6 +63,20 @@ bool CIRGenerator::HandleTopLevelDecl(DeclGroupRef group) {
   return true;
 }
 
+void CIRGenerator::HandleTranslationUnit(ASTContext &astContext) {
+  // Release the Builder when there is no error.
+  if (!diags.hasErrorOccurred() && cgm)
+    cgm->release();
+
+  // If there are errors before or when releasing the CGM, reset the module to
+  // stop here before invoking the backend.
+  if (diags.hasErrorOccurred()) {
+    if (cgm)
+      // TODO: cgm->clear();
----------------
erichkeane wrote:

??

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


More information about the cfe-commits mailing list