[flang-commits] [flang] [flang][OpenMP] Support custom mappers in target update to/from clauses (PR #169673)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Mon Jan 12 06:24:43 PST 2026
================
@@ -1848,32 +1851,49 @@ void OmpVisitor::Post(const parser::OmpStylizedInstance &x) { //
bool OmpVisitor::Pre(const parser::OmpMapClause &x) {
auto &mods{OmpGetModifiers(x)};
if (auto *mapper{OmpGetUniqueModifier<parser::OmpMapper>(mods)}) {
- if (auto *symbol{FindSymbol(currScope(), mapper->v)}) {
- // TODO: Do we need a specific flag or type here, to distinghuish against
- // other ConstructName things? Leaving this for the full implementation
- // of mapper lowering.
- auto &ultimate{symbol->GetUltimate()};
- auto *misc{ultimate.detailsIf<MiscDetails>()};
- auto *md{ultimate.detailsIf<MapperDetails>()};
- if (!md && (!misc || misc->kind() != MiscDetails::Kind::ConstructName))
- context().Say(mapper->v.source,
- "Name '%s' should be a mapper name"_err_en_US, mapper->v.source);
- else
- mapper->v.symbol = symbol;
+ ResolveMapperModifier(const_cast<parser::OmpMapper &>(*mapper));
+ }
+ return true;
+}
+
+bool OmpVisitor::Pre(const parser::OmpClause::To &x) {
+ auto &mods{OmpGetModifiers(x.v)};
+ if (auto *mapper{OmpGetUniqueModifier<parser::OmpMapper>(mods)}) {
+ ResolveMapperModifier(const_cast<parser::OmpMapper &>(*mapper));
+ }
+ return true;
+}
+
+bool OmpVisitor::Pre(const parser::OmpClause::From &x) {
+ auto &mods{OmpGetModifiers(x.v)};
+ if (auto *mapper{OmpGetUniqueModifier<parser::OmpMapper>(mods)}) {
+ ResolveMapperModifier(const_cast<parser::OmpMapper &>(*mapper));
+ }
+ return true;
+}
+
+void OmpVisitor::ResolveMapperModifier(parser::OmpMapper &mapper) {
----------------
kparzysz wrote:
This could be `const parser::OmpMapper &mapper`. IIRC, the "symbol" data members are mutable. This should also remove the need for the const_casts above.
https://github.com/llvm/llvm-project/pull/169673
More information about the flang-commits
mailing list