Skip to content

Commit e075bfb

Browse files
committed
formatting fixes
1 parent 2a5bc0a commit e075bfb

File tree

6 files changed

+89
-71
lines changed

6 files changed

+89
-71
lines changed

flang/include/flang/Parser/parse-tree.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5025,7 +5025,9 @@ struct OpenMPLoopConstruct {
50255025
TUPLE_CLASS_BOILERPLATE(OpenMPLoopConstruct);
50265026
OpenMPLoopConstruct(OmpBeginLoopDirective &&a)
50275027
: t({std::move(a), std::nullopt, std::nullopt}) {}
5028-
std::tuple<OmpBeginLoopDirective, std::optional<std::variant<DoConstruct, common::Indirection<OpenMPLoopConstruct>>>,
5028+
std::tuple<OmpBeginLoopDirective,
5029+
std::optional<
5030+
std::variant<DoConstruct, common::Indirection<OpenMPLoopConstruct>>>,
50295031
std::optional<OmpEndLoopDirective>>
50305032
t;
50315033
};

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,8 +4108,10 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
41084108
converter.genLocation(beginLoopDirective.source);
41094109

41104110
auto &optLoopCons = std::get<1>(loopConstruct.t);
4111-
if(optLoopCons.has_value())
4112-
if(auto *ompNestedLoopCons{std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(&*optLoopCons)}) {
4111+
if (optLoopCons.has_value())
4112+
if (auto *ompNestedLoopCons{
4113+
std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(
4114+
&*optLoopCons)}) {
41134115
genOMP(converter, symTable, semaCtx, eval, ompNestedLoopCons->value());
41144116
}
41154117

flang/lib/Parser/unparse.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2926,7 +2926,8 @@ class UnparseVisitor {
29262926
Walk(std::get<OmpBeginLoopDirective>(x.t));
29272927
Put("\n");
29282928
EndOpenMP();
2929-
Walk(std::get<std::optional<std::variant<DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t));
2929+
Walk(std::get<std::optional<std::variant<DoConstruct,
2930+
common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t));
29302931
Walk(std::get<std::optional<OmpEndLoopDirective>>(x.t));
29312932
}
29322933
void Unparse(const BasedPointer &x) {

flang/lib/Semantics/canonicalize-omp.cpp

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
762762
SetLoopInfo(x);
763763

764764
auto &optLoopCons = std::get<1>(x.t);
765-
if(optLoopCons.has_value()) {
765+
if (optLoopCons.has_value()) {
766766
if (const auto &doConstruct{
767767
std::get_if<parser::DoConstruct>(&*optLoopCons)}) {
768768
const auto &doBlock{std::get<parser::Block>(doConstruct->t)};
@@ -865,26 +865,26 @@ void OmpStructureChecker::CheckLoopItrVariableIsInt(
865865
auto &optLoopCons = std::get<1>(x.t);
866866
if (optLoopCons.has_value()) {
867867
if (const auto &loopConstruct{
868-
std::get_if<parser::DoConstruct>(&*optLoopCons)}) {
868+
std::get_if<parser::DoConstruct>(&*optLoopCons)}) {
869869

870-
for (const parser::DoConstruct *loop{&*loopConstruct}; loop;) {
871-
if (loop->IsDoNormal()) {
872-
const parser::Name &itrVal{GetLoopIndex(loop)};
873-
if (itrVal.symbol) {
874-
const auto *type{itrVal.symbol->GetType()};
875-
if (!type->IsNumeric(TypeCategory::Integer)) {
876-
context_.Say(itrVal.source,
877-
"The DO loop iteration"
878-
" variable must be of the type integer."_err_en_US,
879-
itrVal.ToString());
870+
for (const parser::DoConstruct *loop{&*loopConstruct}; loop;) {
871+
if (loop->IsDoNormal()) {
872+
const parser::Name &itrVal{GetLoopIndex(loop)};
873+
if (itrVal.symbol) {
874+
const auto *type{itrVal.symbol->GetType()};
875+
if (!type->IsNumeric(TypeCategory::Integer)) {
876+
context_.Say(itrVal.source,
877+
"The DO loop iteration"
878+
" variable must be of the type integer."_err_en_US,
879+
itrVal.ToString());
880+
}
880881
}
881882
}
882-
}
883-
// Get the next DoConstruct if block is not empty.
884-
const auto &block{std::get<parser::Block>(loop->t)};
885-
const auto it{block.begin()};
886-
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
887-
: nullptr;
883+
// Get the next DoConstruct if block is not empty.
884+
const auto &block{std::get<parser::Block>(loop->t)};
885+
const auto it{block.begin()};
886+
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
887+
: nullptr;
888888
}
889889
}
890890
}
@@ -1087,25 +1087,25 @@ void OmpStructureChecker::CheckDistLinear(
10871087
// clauses.
10881088
auto &optLoopCons = std::get<1>(x.t);
10891089
if (optLoopCons.has_value()) {
1090-
if (const auto &loopConstruct{
1091-
std::get_if<parser::DoConstruct>(&*optLoopCons)}) {
1092-
for (const parser::DoConstruct *loop{&*loopConstruct}; loop;) {
1093-
if (loop->IsDoNormal()) {
1094-
const parser::Name &itrVal{GetLoopIndex(loop)};
1095-
if (itrVal.symbol) {
1096-
// Remove the symbol from the collected set
1097-
indexVars.erase(&itrVal.symbol->GetUltimate());
1098-
}
1099-
collapseVal--;
1100-
if (collapseVal == 0) {
1101-
break;
1090+
if (const auto &loopConstruct{
1091+
std::get_if<parser::DoConstruct>(&*optLoopCons)}) {
1092+
for (const parser::DoConstruct *loop{&*loopConstruct}; loop;) {
1093+
if (loop->IsDoNormal()) {
1094+
const parser::Name &itrVal{GetLoopIndex(loop)};
1095+
if (itrVal.symbol) {
1096+
// Remove the symbol from the collected set
1097+
indexVars.erase(&itrVal.symbol->GetUltimate());
1098+
}
1099+
collapseVal--;
1100+
if (collapseVal == 0) {
1101+
break;
1102+
}
11021103
}
1103-
}
1104-
// Get the next DoConstruct if block is not empty.
1105-
const auto &block{std::get<parser::Block>(loop->t)};
1106-
const auto it{block.begin()};
1107-
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
1108-
: nullptr;
1104+
// Get the next DoConstruct if block is not empty.
1105+
const auto &block{std::get<parser::Block>(loop->t)};
1106+
const auto it{block.begin()};
1107+
loop = it != block.end() ? parser::Unwrap<parser::DoConstruct>(*it)
1108+
: nullptr;
11091109
}
11101110
}
11111111
}

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,10 +1968,11 @@ void OmpAttributeVisitor::PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
19681968
auto &optLoopCons = std::get<1>(x.t);
19691969
if (optLoopCons.has_value()) {
19701970
if (const auto &outer{std::get_if<parser::DoConstruct>(&*optLoopCons)}) {
1971-
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0; --level) {
1971+
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0;
1972+
--level) {
19721973
if (loop->IsDoConcurrent()) {
1973-
// DO CONCURRENT is explicitly allowed for the LOOP construct so long as
1974-
// there isn't a COLLAPSE clause
1974+
// DO CONCURRENT is explicitly allowed for the LOOP construct so long
1975+
// as there isn't a COLLAPSE clause
19751976
if (isLoopConstruct) {
19761977
if (hasCollapseClause) {
19771978
// hasCollapseClause implies clause != nullptr
@@ -2000,16 +2001,20 @@ void OmpAttributeVisitor::PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
20002001
}
20012002
}
20022003
CheckAssocLoopLevel(level, GetAssociatedClause());
2003-
} else if (const auto &loop{std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(&*optLoopCons)}) {
2004+
} else if (const auto &loop{std::get_if<
2005+
common::Indirection<parser::OpenMPLoopConstruct>>(
2006+
&*optLoopCons)}) {
20042007
auto &beginDirective =
2005-
std::get<parser::OmpBeginLoopDirective>(loop->value().t);
2008+
std::get<parser::OmpBeginLoopDirective>(loop->value().t);
20062009
auto &beginLoopDirective =
20072010
std::get<parser::OmpLoopDirective>(beginDirective.t);
20082011
if ((beginLoopDirective.v != llvm::omp::Directive::OMPD_unroll &&
2009-
beginLoopDirective.v != llvm::omp::Directive::OMPD_tile)) {
2012+
beginLoopDirective.v != llvm::omp::Directive::OMPD_tile)) {
20102013
context_.Say(GetContext().directiveSource,
2011-
"Only UNROLL or TILE constructs are allowed between an OpenMP Loop Construct and a DO construct"_err_en_US,
2012-
parser::ToUpperCaseLetters(llvm::omp::getOpenMPDirectiveName(GetContext().directive, version).str()));
2014+
"Only UNROLL or TILE constructs are allowed between an OpenMP Loop Construct and a DO construct"_err_en_US,
2015+
parser::ToUpperCaseLetters(llvm::omp::getOpenMPDirectiveName(
2016+
GetContext().directive, version)
2017+
.str()));
20132018
} else {
20142019
PrivatizeAssociatedLoopIndexAndCheckLoopLevel(loop->value());
20152020
}

0 commit comments

Comments
 (0)