[clang] [OpenMP] Support capturing structured bindings in OpenMP regions. (PR #190832)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 6 06:51:41 PDT 2026


================
@@ -3779,6 +3828,25 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
   // an enclosing scope.
   if (const auto *BD = dyn_cast<BindingDecl>(ND)) {
     if (E->refersToEnclosingVariableOrCapture()) {
+      // Try direct lookup first.
+      auto It = LocalDeclMap.find(BD->getCanonicalDecl());
+      if (It != LocalDeclMap.end()) {
+        return MakeAddrLValue(It->second, E->getType(), AlignmentSource::Decl);
+      }
+      // OpenMP case: binding was captured via its decomposed decl.
+      if (CapturedStmtInfo &&
+          CapturedStmtInfo->getKind() == CapturedRegionKind::CR_OpenMP &&
+          CGM.getLangOpts().OpenMP) {
+        auto NameIt = OMPPrivatizedBindingsByName.find(BD->getName());
----------------
alexey-bataev wrote:

Probably, need to use the decl identity, otherwise might be a conflict if several BindingDecls with the same name from different DecompositionDecls are live in overlapping OpenMP privatization scopes 

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


More information about the cfe-commits mailing list