================
@@ -3592,6 +3592,53 @@ 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 && "Expected to be inside a captured region");
+ assert(CapturedStmtInfo->getKind() == CapturedRegionKind::CR_OpenMP &&
+ "Expected OpenMP captured region");
+ assert(CGM.getLangOpts().OpenMP && "Expected OpenMP to be enabled");
+
+ auto *DD = cast<VarDecl>(BD->getDecomposedDecl());
+ Expr *BindingExpr = BD->getBinding()->IgnoreImplicit();
+ QualType DREType = DD->getType().getNonReferenceType();
+ DeclarationNameInfo NameInfo(DD->getDeclName(), SourceLocation());
+ DeclRefExpr *DRE = DeclRefExpr::Create(
+ getContext(), NestedNameSpecifierLoc(), SourceLocation(), DD,
+ /*RefersToEnclosingVariableOrCapture=*/true, NameInfo, DREType,
+ VK_LValue);
+ LValue BaseLVal = EmitDeclRefLValue(DRE);
+ QualType CanonType = DREType.getCanonicalType();
+ Address Addr = BaseLVal.getAddress();
+ llvm::Type *ExpectedTy = CGM.getTypes().ConvertTypeForMem(CanonType);
+ if (auto *ASE = dyn_cast<ArraySubscriptExpr>(BindingExpr)) {
+ if (Addr.getElementType() != ExpectedTy)
+ Addr = Addr.withElementType(ExpectedTy);
+
+ Expr::EvalResult Result;
+ ASE->getIdx()->EvaluateAsInt(Result, getContext());
----------------
alexey-bataev wrote:
Check the result and at least add the assertion.
https://github.com/llvm/llvm-project/pull/190832
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits