[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 06:13:51 PDT 2026
================
@@ -3771,6 +3771,99 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
// an enclosing scope.
if (const auto *BD = dyn_cast<BindingDecl>(ND)) {
if (E->refersToEnclosingVariableOrCapture()) {
+ // OpenMP case: binding was captured via its decomposed decl.
+ if (auto *DD = dyn_cast<VarDecl>(BD->getDecomposedDecl())) {
+ if (CapturedStmtInfo &&
+ CapturedStmtInfo->getKind() == CapturedRegionKind::CR_OpenMP &&
+ CGM.getLangOpts().OpenMP) {
+ auto I = LocalDeclMap.find(DD);
+ if (I != LocalDeclMap.end()) {
----------------
erichkeane wrote:
I'm having trouble following to find the 'else' here, but this should never fail if the binding decl is in scope.
Also, this stuff is only supposed to be used from the EmitDeclRef type functions, we shouldn't be accessing this directly. You should do the 'emit declref, and adjust types with casts, not try to coerce the type below.
https://github.com/llvm/llvm-project/pull/190832
More information about the cfe-commits
mailing list