================
@@ -22576,14 +22800,91 @@ class MapBaseChecker final : public
StmtVisitor<MapBaseChecker, bool> {
public:
bool VisitDeclRefExpr(DeclRefExpr *DRE) {
- if (!isa<VarDecl>(DRE->getDecl())) {
+ ValueDecl *D = DRE->getDecl();
+ Expr *E = DRE;
+
+ // Handle BindingDecls by mapping them as member accesses.
+ // When the user writes:
+ // auto [a, b] = p;
+ // #pragma omp target map(tofrom:a) map(to:b)
+ // we transform it to:
+ // #pragma omp target map(tofrom:p.x) map(to:p.y)
+ // This avoids conflicts when different bindings have different map types.
+ if (auto *BD = dyn_cast<BindingDecl>(D)) {
+ auto *DD = cast<DecompositionDecl>(BD->getDecomposedDecl());
+ Expr *BindingExpr = BD->getBinding();
+
+ // Check if the binding is a member expression (struct/class
+ // decomposition).
+ if (auto *ME = dyn_cast_or_null<MemberExpr>(BindingExpr)) {
+
+ // Get the original variable that the decomposition was initialized
+ // from.
+ if (const VarDecl *OrigVar =
+ +getOriginalVarOrDiagnose(SemaRef, DD, DRE->getExprLoc())) {
----------------
alexey-bataev wrote:
```suggestion
getOriginalVarOrDiagnose(SemaRef, DD, DRE->getExprLoc())) {
```
https://github.com/llvm/llvm-project/pull/190832
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits