[clang] [OpenMP] Support capturing structured bindings in OpenMP regions. (PR #190832)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 4 09:43:58 PDT 2026
================
@@ -1152,11 +1154,35 @@ bool CodeGenFunction::EmitOMPFirstprivateClause(const OMPExecutableDirective &D,
const auto *IRef = C->varlist_begin();
const auto *InitsRef = C->inits().begin();
for (const Expr *IInit : C->private_copies()) {
- const auto *OrigVD = cast<VarDecl>(cast<DeclRefExpr>(*IRef)->getDecl());
+ const auto *OrigDecl = cast<DeclRefExpr>(*IRef)->getDecl();
+ const VarDecl *OrigVD = dyn_cast<VarDecl>(OrigDecl);
+ const auto *VD = cast<VarDecl>(cast<DeclRefExpr>(IInit)->getDecl());
+
+ if (const auto *BD = dyn_cast<BindingDecl>(OrigDecl)) {
+ Address PrivateAddr = CreateMemTemp(VD->getType(), VD->getName());
+ DeclRefExpr DRE(getContext(), const_cast<BindingDecl *>(BD),
+ /*RefersToEnclosingVariableOrCapture=*/true,
+ BD->getType(), VK_LValue, (*IRef)->getExprLoc());
+ LValue OriginalLVal = EmitLValue(&DRE);
+ RValue OrigValue =
+ EmitLoadOfLValue(OriginalLVal, (*IRef)->getExprLoc());
+ EmitStoreThroughLValue(OrigValue,
+ MakeAddrLValue(PrivateAddr, VD->getType()));
----------------
zahiraam wrote:
Fixed and added test case.
https://github.com/llvm/llvm-project/pull/190832
More information about the cfe-commits
mailing list