[clang] [CIR] Upstream support for function-level variable decompositions (PR #151073)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 29 08:04:01 PDT 2025


================
@@ -608,11 +608,16 @@ void CIRGenFunction::emitDecl(const Decl &d) {
   case Decl::UsingDirective: // using namespace X; [C++]
     assert(!cir::MissingFeatures::generateDebugInfo());
     return;
-  case Decl::Var: {
+  case Decl::Var:
+  case Decl::Decomposition: {
     const VarDecl &vd = cast<VarDecl>(d);
     assert(vd.isLocalVarDecl() &&
            "Should not see file-scope variables inside a function!");
     emitVarDecl(vd);
+    if (auto *dd = dyn_cast<DecompositionDecl>(&vd))
+      for (BindingDecl *b : dd->bindings())
+        if (VarDecl *hd = b->getHoldingVar())
+          emitVarDecl(*hd);
----------------
xlauko wrote:

This differs from classic codegen. Can we align here, i.e. introduce `maybeEmitDeferredVarDeclInit` and use the same implementation as `CodeGenFunction::MaybeEmitDeferredVarDeclInit`

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


More information about the cfe-commits mailing list