================
@@ -1783,6 +1783,98 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+                               mlir::omp::MapInfoOp memberOp) {
+  int memberDataIdx = -1;
+  for (size_t i = 0; i < mapData.MapClause.size(); ++i) {
+    if (mapData.MapClause[i] == memberOp)
+      memberDataIdx = i;
+  }
+  return memberDataIdx;
+}
----------------
ergawy wrote:

`std::find_if(...)`, just like the other PR 😛.

Also it seems like all the uses of this function assume that `-1` will not be 
returned (there has to be an element matching the search key). So, I would 
suggest:
```suggestion
static int getMapDataMemberIdx(MapInfoData &mapData,
                               mlir::omp::MapInfoOp memberOp) {
  auto res = llvm::find(mapData.MapClause, memberOp);
  assert(res != mapData.MapClause.end());
  return std::distance(mapData.MapClause.begin(), res);
}
```

https://github.com/llvm/llvm-project/pull/81510
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to