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

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sat May 9 09:14:42 PDT 2026


================
@@ -1970,9 +1970,14 @@ ExprResult Sema::BuildCaptureInit(const Capture &Cap,
   } else {
     assert(Cap.isVariableCapture() && "unknown kind of capture");
     ValueDecl *Var = Cap.getVariable();
+    // For OpenMP structured bindings, capture the decomposed decl, not the
+    // binding.
+    if (IsOpenMPMapping && isa<BindingDecl>(Var)) {
+      Var = cast<BindingDecl>(Var)->getDecomposedDecl();
----------------
alexey-bataev wrote:

Redundant `cast<BindingDecl>(Var)` after `isa<BindingDecl>(Var)`. Use `auto *BD = dyn_cast<BindingDecl>(Var); if (IsOpenMPMapping && BD) Var = BD->getDecomposedDecl();`. Also drop the trailing braces around the single statement to match the surrounding style.

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


More information about the cfe-commits mailing list