@@ -109,8 +109,8 @@ class CanonicalizationOfOmp {
109109
110110 void missingDoConstruct (parser::OmpLoopDirective &dir) {
111111 messages_.Say (dir.source ,
112- " A DO loop must follow the %s directive" _err_en_US,
113- parser::ToUpperCaseLetters (dir.source .ToString ()));
112+ " A DO loop must follow the %s directive" _err_en_US,
113+ parser::ToUpperCaseLetters (dir.source .ToString ()));
114114 }
115115
116116 void RewriteOpenMPLoopConstruct (parser::OpenMPLoopConstruct &x,
@@ -142,7 +142,8 @@ class CanonicalizationOfOmp {
142142 if (auto *doCons{GetConstructIf<parser::DoConstruct>(*nextIt)}) {
143143 if (doCons->GetLoopControl ()) {
144144 // move DoConstruct
145- std::get<std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t ) =
145+ std::get<std::optional<std::variant<parser::DoConstruct,
146+ common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t ) =
146147 std::move (*doCons);
147148 nextIt = block.erase (nextIt);
148149 // try to match OmpEndLoopDirective
@@ -159,39 +160,46 @@ class CanonicalizationOfOmp {
159160 }
160161 } else if (auto *ompLoopCons{
161162 GetOmpIf<parser::OpenMPLoopConstruct>(*nextIt)}) {
162- // We should allow UNROLL and TILE constructs to be inserted between an OpenMP Loop Construct and the DO loop itself
163+ // We should allow UNROLL and TILE constructs to be inserted between an
164+ // OpenMP Loop Construct and the DO loop itself
163165 auto &beginDirective =
164166 std::get<parser::OmpBeginLoopDirective>(ompLoopCons->t );
165167 auto &beginLoopDirective =
166- std::get<parser::OmpLoopDirective>(beginDirective.t );
168+ std::get<parser::OmpLoopDirective>(beginDirective.t );
167169 if ((beginLoopDirective.v == llvm::omp::Directive::OMPD_unroll ||
168- beginLoopDirective.v == llvm::omp::Directive::OMPD_tile)) {
169- // iterate through the remaining block items to find the end directive for the unroll/tile directive.
170+ beginLoopDirective.v == llvm::omp::Directive::OMPD_tile)) {
171+ // iterate through the remaining block items to find the end directive
172+ // for the unroll/tile directive.
170173 parser::Block::iterator endIt;
171174 endIt = nextIt;
172- while (endIt != block.end ()) {
175+ while (endIt != block.end ()) {
173176 if (auto *endDir{
174- GetConstructIf<parser::OmpEndLoopDirective>(*endIt)}) {
175- auto &endLoopDirective = std::get<parser::OmpLoopDirective>(endDir-> t );
176- if (endLoopDirective. v == dir. v ) {
177- std::get<std::optional<parser::OmpEndLoopDirective>>(x. t ) =
178- std::move (*endDir);
179- endIt = block. erase (endIt );
180- continue ;
181- }
177+ GetConstructIf<parser::OmpEndLoopDirective>(*endIt)}) {
178+ auto &endLoopDirective =
179+ std::get<parser::OmpLoopDirective>(endDir-> t );
180+ if (endLoopDirective. v == dir. v ) {
181+ std::get<std::optional<parser::OmpEndLoopDirective>>(x. t ) =
182+ std::move (*endDir );
183+ endIt = block. erase (endIt) ;
184+ continue ;
182185 }
183- ++endIt;
184186 }
187+ ++endIt;
188+ }
185189 RewriteOpenMPLoopConstruct (*ompLoopCons, block, nextIt);
186- auto &ompLoop = std::get<std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t );
187- ompLoop = std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>{
188- std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>{
189- common::Indirection{std::move (*ompLoopCons)}}};
190+ auto &ompLoop =
191+ std::get<std::optional<std::variant<parser::DoConstruct,
192+ common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t );
193+ ompLoop = std::optional<std::variant<parser::DoConstruct,
194+ common::Indirection<parser::OpenMPLoopConstruct>>>{
195+ std::variant<parser::DoConstruct,
196+ common::Indirection<parser::OpenMPLoopConstruct>>{
197+ common::Indirection{std::move (*ompLoopCons)}}};
190198 nextIt = block.erase (nextIt);
191199 } else {
192200 messages_.Say (dir.source ,
193- " Only OpenMP Loop Transformation Constructs can be nested within OpenMPLoopConstruct's" _err_en_US,
194- parser::ToUpperCaseLetters (dir.source .ToString ()));
201+ " Only OpenMP Loop Transformation Constructs can be nested within OpenMPLoopConstruct's" _err_en_US,
202+ parser::ToUpperCaseLetters (dir.source .ToString ()));
195203 }
196204 } else {
197205 missingDoConstruct (dir);
0 commit comments