@@ -1109,28 +1109,26 @@ Order make(const parser::OmpClause::Order &inp,
11091109 using wrapped = parser::OmpOrderClause;
11101110
11111111 CLAUSET_ENUM_CONVERT ( //
1112- convert1, parser::OmpOrderModifier::Kind , Order::OrderModifier,
1112+ convert1, parser::OmpOrderModifier::Value , Order::OrderModifier,
11131113 // clang-format off
11141114 MS (Reproducible, Reproducible)
11151115 MS (Unconstrained, Unconstrained)
11161116 // clang-format on
11171117 );
11181118
11191119 CLAUSET_ENUM_CONVERT ( //
1120- convert2, wrapped::Type , Order::Ordering,
1120+ convert2, wrapped::Ordering , Order::Ordering,
11211121 // clang-format off
11221122 MS (Concurrent, Concurrent)
11231123 // clang-format on
11241124 );
11251125
1126- auto &t0 = std::get<std::optional<parser::OmpOrderModifier>>(inp.v .t );
1127- auto &t1 = std::get<wrapped::Type>(inp.v .t );
1126+ auto &mods = semantics::OmpGetModifiers (inp.v );
1127+ auto *t0 = semantics::OmpGetUniqueModifier<parser::OmpOrderModifier>(mods);
1128+ auto &t1 = std::get<wrapped::Ordering>(inp.v .t );
11281129
1129- auto convert3 = [&](const parser::OmpOrderModifier &s) {
1130- return convert1 (s.v );
1131- };
1132- return Order{
1133- {/* OrderModifier=*/ maybeApply (convert3, t0), /* Ordering=*/ convert2 (t1)}};
1130+ return Order{{/* OrderModifier=*/ maybeApplyToV (convert1, t0),
1131+ /* Ordering=*/ convert2 (t1)}};
11341132}
11351133
11361134Ordered make (const parser::OmpClause::Ordered &inp,
@@ -1197,10 +1195,10 @@ Reduction make(const parser::OmpClause::Reduction &inp,
11971195 auto *t1 =
11981196 semantics::OmpGetUniqueModifier<parser::OmpReductionIdentifier>(mods);
11991197 auto &t2 = std::get<parser::OmpObjectList>(inp.v .t );
1198+ assert (t1 && " OmpReductionIdentifier is required" );
1199+
12001200 return Reduction{
1201- {/* ReductionModifier=*/ t0
1202- ? std::make_optional<Reduction::ReductionModifier>(convert (t0->v ))
1203- : std::nullopt ,
1201+ {/* ReductionModifier=*/ maybeApplyToV (convert, t0),
12041202 /* ReductionIdentifiers=*/ {makeReductionOperator (*t1, semaCtx)},
12051203 /* List=*/ makeObjects (t2, semaCtx)}};
12061204}
@@ -1221,7 +1219,7 @@ Schedule make(const parser::OmpClause::Schedule &inp,
12211219 using wrapped = parser::OmpScheduleClause;
12221220
12231221 CLAUSET_ENUM_CONVERT ( //
1224- convert1, wrapped::ScheduleType , Schedule::Kind,
1222+ convert1, wrapped::Kind , Schedule::Kind,
12251223 // clang-format off
12261224 MS (Static, Static)
12271225 MS (Dynamic, Dynamic)
@@ -1232,57 +1230,30 @@ Schedule make(const parser::OmpClause::Schedule &inp,
12321230 );
12331231
12341232 CLAUSET_ENUM_CONVERT ( //
1235- convert2, parser::OmpScheduleModifierType::ModType,
1236- Schedule::OrderingModifier,
1233+ convert2, parser::OmpOrderingModifier::Value, Schedule::OrderingModifier,
12371234 // clang-format off
12381235 MS (Monotonic, Monotonic)
12391236 MS (Nonmonotonic, Nonmonotonic)
12401237 // clang-format on
12411238 );
12421239
12431240 CLAUSET_ENUM_CONVERT ( //
1244- convert3, parser::OmpScheduleModifierType::ModType,
1245- Schedule::ChunkModifier,
1241+ convert3, parser::OmpChunkModifier::Value, Schedule::ChunkModifier,
12461242 // clang-format off
12471243 MS (Simd, Simd)
12481244 // clang-format on
12491245 );
12501246
1251- auto &t0 = std::get<std::optional<parser::OmpScheduleModifier>>(inp.v .t );
1252- auto &t1 = std::get<wrapped::ScheduleType>(inp.v .t );
1253- auto &t2 = std::get<std::optional<parser::ScalarIntExpr>>(inp.v .t );
1254-
1255- if (!t0) {
1256- return Schedule{{/* Kind=*/ convert1 (t1), /* OrderingModifier=*/ std::nullopt ,
1257- /* ChunkModifier=*/ std::nullopt ,
1258- /* ChunkSize=*/ maybeApply (makeExprFn (semaCtx), t2)}};
1259- }
1260-
1261- // The members of parser::OmpScheduleModifier correspond to OrderingModifier,
1262- // and ChunkModifier, but they can appear in any order.
1263- auto &m1 = std::get<parser::OmpScheduleModifier::Modifier1>(t0->t );
1264- auto &m2 =
1265- std::get<std::optional<parser::OmpScheduleModifier::Modifier2>>(t0->t );
1266-
1267- std::optional<Schedule::OrderingModifier> omod;
1268- std::optional<Schedule::ChunkModifier> cmod;
1269-
1270- if (m1.v .v == parser::OmpScheduleModifierType::ModType::Simd) {
1271- // m1 is chunk-modifier
1272- cmod = convert3 (m1.v .v );
1273- if (m2)
1274- omod = convert2 (m2->v .v );
1275- } else {
1276- // m1 is ordering-modifier
1277- omod = convert2 (m1.v .v );
1278- if (m2)
1279- cmod = convert3 (m2->v .v );
1280- }
1247+ auto &mods = semantics::OmpGetModifiers (inp.v );
1248+ auto *t0 = semantics::OmpGetUniqueModifier<parser::OmpOrderingModifier>(mods);
1249+ auto *t1 = semantics::OmpGetUniqueModifier<parser::OmpChunkModifier>(mods);
1250+ auto &t2 = std::get<wrapped::Kind>(inp.v .t );
1251+ auto &t3 = std::get<std::optional<parser::ScalarIntExpr>>(inp.v .t );
12811252
1282- return Schedule{{/* Kind=*/ convert1 (t1 ),
1283- /* OrderingModifier=*/ omod ,
1284- /* ChunkModifier=*/ cmod ,
1285- /* ChunkSize=*/ maybeApply (makeExprFn (semaCtx), t2 )}};
1253+ return Schedule{{/* Kind=*/ convert1 (t2 ),
1254+ /* OrderingModifier=*/ maybeApplyToV (convert2, t0) ,
1255+ /* ChunkModifier=*/ maybeApplyToV (convert3, t1) ,
1256+ /* ChunkSize=*/ maybeApply (makeExprFn (semaCtx), t3 )}};
12861257}
12871258
12881259// SeqCst: empty
@@ -1326,6 +1297,8 @@ TaskReduction make(const parser::OmpClause::TaskReduction &inp,
13261297 auto *t0 =
13271298 semantics::OmpGetUniqueModifier<parser::OmpReductionIdentifier>(mods);
13281299 auto &t1 = std::get<parser::OmpObjectList>(inp.v .t );
1300+ assert (t0 && " OmpReductionIdentifier is required" );
1301+
13291302 return TaskReduction{
13301303 {/* ReductionIdentifiers=*/ {makeReductionOperator (*t0, semaCtx)},
13311304 /* List=*/ makeObjects (t1, semaCtx)}};
0 commit comments