[clang] [OpenMP] Support capturing structured bindings in OpenMP regions. (PR #190832)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 19 09:10:01 PDT 2026
================
@@ -1227,8 +1235,16 @@ class CodeGenFunction : public CodeGenTypeCache {
/// PrivateGen is the address of the generated private variable.
/// \return true if the variable is registered as private, false if it has
/// been privatized already.
- bool addPrivate(const VarDecl *LocalVD, Address Addr) {
+ bool addPrivate(const ValueDecl *LocalVD, Address Addr) {
assert(PerformCleanup && "adding private to dead scope");
+ if (const auto *BD = dyn_cast<BindingDecl>(LocalVD->getCanonicalDecl())) {
+ auto It = CGF.OMPPrivatizedBindings.find(BD);
+ if (It != CGF.OMPPrivatizedBindings.end()) {
+ BindingChanges.emplace_back(BD, It->second);
+ } else {
+ BindingChanges.emplace_back(BD, std::nullopt);
+ }
----------------
zahiraam wrote:
I switched to A`ddress::invalid()` as you suggested, avoiding `std::optional`.
However, `lookup()` doesn't work because `Address` has no default constructor, so
I'm using the explicit `find(`) pattern which is the standard one for
non-default-constructible map values.
https://github.com/llvm/llvm-project/pull/190832
More information about the cfe-commits
mailing list