[flang-commits] [flang] [flang][OpenMP] Support custom mappers in target update to/from clauses (PR #169673)

Krish Gupta via flang-commits flang-commits at lists.llvm.org
Thu Jan 15 07:54:36 PST 2026


================
@@ -1437,6 +1446,41 @@ void ClauseProcessor::processMapObjects(
   }
 }
 
+/// Extract and mangle the mapper identifier name from a mapper clause.
+/// Returns "__implicit_mapper" if no mapper is specified, or "default" if
+/// the default mapper is specified, otherwise returns the mangled mapper name.
+/// This handles both the Map clause (which uses a vector of mappers) and
+/// To/From clauses (which use a DefinedOperator).
+template <typename MapperType>
+static std::string
+getMapperIdentifier(lower::AbstractConverter &converter,
+                    const std::optional<MapperType> &mapper) {
+  std::string mapperIdName = "__implicit_mapper";
+  if (mapper) {
+    const semantics::Symbol *mapperSym = nullptr;
+
+    // Handle different mapper types
+    if constexpr (std::is_same_v<MapperType, omp::clause::DefinedOperator>) {
+      // For To/From clauses: mapper is a DefinedOperator
+      assert(mapper->size() == 1 && "more than one mapper");
+      mapperSym = mapper->front().v.id().symbol;
+    } else {
+      // For Map clause: mappers is a vector
+      assert(mapper->size() == 1 && "more than one mapper");
+      mapperSym = mapper->front().v.id().symbol;
+    }
----------------
KrxGu wrote:

Done! Simplified the function with early return and removed the redundant if constexpr - both branches were doing the same thing anyway. Much cleaner now, thanks for catching that!

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


More information about the flang-commits mailing list