[clang] [OpenMP] Support capturing structured bindings in OpenMP regions. (PR #190832)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 14:06:29 PDT 2026
================
@@ -3589,6 +3589,61 @@ static bool canEmitSpuriousReferenceToVariable(CodeGenFunction &CGF,
}
}
+/// Emit an LValue for a structured binding captured in an OpenMP region.
+/// Handles extracting individual bindings from the captured decomposed
+/// declaration (struct fields, array elements, etc.).
+LValue CodeGenFunction::EmitOMPCapturedBindingLValue(const BindingDecl *BD) {
+ assert(CapturedStmtInfo &&
+ CapturedStmtInfo->getKind() == CapturedRegionKind::CR_OpenMP &&
+ CGM.getLangOpts().OpenMP);
+ auto *DD = cast<VarDecl>(BD->getDecomposedDecl());
+ auto I = LocalDeclMap.find(DD);
+ assert(I != LocalDeclMap.end() && "Decomposed decl not in LocalDeclMap");
+
+ Address ParamAddr = I->second;
+ QualType AggregType = DD->getType();
+ if (AggregType->isReferenceType())
+ AggregType = AggregType->getPointeeType();
+
+ LValue CapLVal;
+ llvm::Type *ParamLLVMType = ParamAddr.getElementType();
+ if (ParamLLVMType->isPointerTy()) {
+ llvm::Value *Ptr = Builder.CreateLoad(ParamAddr, "captured.val");
----------------
erichkeane wrote:
We shouldn't really need `ParamAddr`, I would expect us to do a `emitLValue` or similar to get this instead.
And the type should come from the AST, else this is a bit of a 'rewriting history'.
https://github.com/llvm/llvm-project/pull/190832
More information about the cfe-commits
mailing list