Skip to content

Commit 2370fb7

Browse files
committed
Addressed review comments and changed object name check with object symbol check.
1 parent 2e9e552 commit 2370fb7

File tree

2 files changed

+47
-53
lines changed

2 files changed

+47
-53
lines changed

flang/lib/Parser/unparse.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,21 +2167,21 @@ class UnparseVisitor {
21672167
void Unparse(const OmpInitClause &x) {
21682168
using Modifier = OmpInitClause::Modifier;
21692169
auto &modifiers{std::get<std::optional<std::list<Modifier>>>(x.t)};
2170-
bool is_type_start = true;
2170+
bool isTypeStart = true;
21712171
for (const Modifier &m : *modifiers) {
2172-
if (auto *interop_preference_mod{
2172+
if (auto *interopPreferenceMod{
21732173
std::get_if<parser::OmpInteropPreference>(&m.u)}) {
21742174
Put("PREFER_TYPE(");
2175-
Walk(*interop_preference_mod);
2175+
Walk(*interopPreferenceMod);
21762176
Put("),");
2177-
} else if (auto *interop_type_mod{
2177+
} else if (auto *interopTypeMod{
21782178
std::get_if<parser::OmpInteropType>(&m.u)}) {
2179-
if (is_type_start) {
2180-
is_type_start = false;
2179+
if (isTypeStart) {
2180+
isTypeStart = false;
21812181
} else {
21822182
Put(",");
21832183
}
2184-
Walk(*interop_type_mod);
2184+
Walk(*interopTypeMod);
21852185
}
21862186
}
21872187
Put(": ");

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

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5582,86 +5582,80 @@ void OmpStructureChecker::Enter(const parser::OpenMPInteropConstruct &x) {
55825582
bool isDependClauseOccured{false};
55835583
int targetCount{0}, targetSyncCount{0};
55845584
const auto &dir{std::get<parser::Verbatim>(x.t)};
5585-
std::list<std::string> ObjectNameList;
5585+
std::set<const Symbol *> objectSymbolList;
55865586
PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_interop);
55875587
const auto &clauseList{std::get<parser::OmpClauseList>(x.t)};
55885588
for (const auto &clause : clauseList.v) {
55895589
common::visit(
55905590
common::visitors{
5591-
[&](const parser::OmpClause::Init &InitClause) {
5592-
if (OmpVerifyModifiers(InitClause.v, llvm::omp::OMPC_init,
5593-
GetContext().directiveSource, context_)) {
5591+
[&](const parser::OmpClause::Init &initClause) {
5592+
if (OmpVerifyModifiers(initClause.v, llvm::omp::OMPC_init,
5593+
GetContext().directiveSource, context_)) {
55945594

5595-
auto &modifiers{OmpGetModifiers(InitClause.v)};
5595+
auto &modifiers{OmpGetModifiers(initClause.v)};
55965596
auto &&interopTypeModifier{
55975597
OmpGetRepeatableModifier<parser::OmpInteropType>(
55985598
modifiers)};
5599-
for (auto it{interopTypeModifier.begin()},
5600-
end{interopTypeModifier.end()};
5601-
it != end; ++it) {
5602-
if (parser::ToUpperCaseLetters(
5603-
parser::OmpInteropType::EnumToString((*it)->v)) ==
5604-
"TARGETSYNC") {
5599+
for (const auto &it : interopTypeModifier) {
5600+
if (it->v == parser::OmpInteropType::Value::TargetSync) {
56055601
++targetSyncCount;
56065602
} else {
56075603
++targetCount;
56085604
}
5609-
if (targetCount > 1 || targetSyncCount > 1) {
5610-
context_.Say(GetContext().directiveSource,
5611-
"Each interop-type may be specified at most once."_err_en_US);
5612-
}
56135605
}
56145606
}
5615-
const auto &InteropVar{parser::Unwrap<parser::OmpObject>(
5616-
std::get<parser::OmpObject>(InitClause.v.t))};
5617-
const auto *name{parser::Unwrap<parser::Name>(InteropVar)};
5618-
const auto ObjectName{name->ToString()};
5619-
if (ObjectNameList.end() !=
5620-
std::find(ObjectNameList.begin(), ObjectNameList.end(),
5621-
ObjectName)) {
5622-
context_.Say(GetContext().directiveSource,
5607+
const auto &interopVar{parser::Unwrap<parser::OmpObject>(
5608+
std::get<parser::OmpObject>(initClause.v.t))};
5609+
const auto *name{parser::Unwrap<parser::Name>(interopVar)};
5610+
const auto *objectSymbol{name->symbol};
5611+
if (llvm::is_contained(objectSymbolList, objectSymbol)) {
5612+
context_.Say(
5613+
GetContext().directiveSource,
56235614
"Each interop-var may be specified for at most one action-clause of each interop construct."_err_en_US);
56245615
} else {
5625-
ObjectNameList.push_back(ObjectName);
5616+
objectSymbolList.insert(objectSymbol);
56265617
}
56275618
},
5628-
[&](const parser::OmpClause::Depend &DependClause) {
5619+
[&](const parser::OmpClause::Depend &dependClause) {
56295620
isDependClauseOccured = true;
56305621
},
5631-
[&](const parser::OmpClause::Destroy &DestroyClause) {
5632-
const auto &InteropVar{
5633-
parser::Unwrap<parser::OmpObject>(DestroyClause.v)};
5634-
const auto *name{parser::Unwrap<parser::Name>(InteropVar)};
5635-
const auto ObjectName{name->ToString()};
5636-
if (ObjectNameList.end() !=
5637-
std::find(ObjectNameList.begin(), ObjectNameList.end(),
5638-
ObjectName)) {
5639-
context_.Say(GetContext().directiveSource,
5622+
[&](const parser::OmpClause::Destroy &destroyClause) {
5623+
const auto &interopVar{
5624+
parser::Unwrap<parser::OmpObject>(destroyClause.v)};
5625+
const auto *name{parser::Unwrap<parser::Name>(interopVar)};
5626+
const auto *objectSymbol{name->symbol};
5627+
if (llvm::is_contained(objectSymbolList, objectSymbol)) {
5628+
context_.Say(
5629+
GetContext().directiveSource,
56405630
"Each interop-var may be specified for at most one action-clause of each interop construct."_err_en_US);
56415631
} else {
5642-
ObjectNameList.push_back(ObjectName);
5632+
objectSymbolList.insert(objectSymbol);
56435633
}
56445634
},
5645-
[&](const parser::OmpClause::Use &UseClause) {
5646-
const auto &InteropVar{
5647-
parser::Unwrap<parser::OmpObject>(UseClause.v)};
5648-
const auto *name{parser::Unwrap<parser::Name>(InteropVar)};
5649-
const auto ObjectName{name->ToString()};
5650-
if (ObjectNameList.end() !=
5651-
std::find(ObjectNameList.begin(), ObjectNameList.end(),
5652-
ObjectName)) {
5653-
context_.Say(GetContext().directiveSource,
5635+
[&](const parser::OmpClause::Use &useClause) {
5636+
const auto &interopVar{
5637+
parser::Unwrap<parser::OmpObject>(useClause.v)};
5638+
const auto *name{parser::Unwrap<parser::Name>(interopVar)};
5639+
const auto *objectSymbol{name->symbol};
5640+
if (llvm::is_contained(objectSymbolList, objectSymbol)) {
5641+
context_.Say(
5642+
GetContext().directiveSource,
56545643
"Each interop-var may be specified for at most one action-clause of each interop construct."_err_en_US);
56555644
} else {
5656-
ObjectNameList.push_back(ObjectName);
5645+
objectSymbolList.insert(objectSymbol);
56575646
}
56585647
},
56595648
[&](const auto &) {},
56605649
},
56615650
clause.u);
56625651
}
5663-
if (isDependClauseOccured && !targetSyncCount) {
5652+
if (targetCount > 1 || targetSyncCount > 1) {
56645653
context_.Say(GetContext().directiveSource,
5654+
"Each interop-type may be specified at most once."_err_en_US);
5655+
}
5656+
if (isDependClauseOccured && !targetSyncCount) {
5657+
context_.Say(
5658+
GetContext().directiveSource,
56655659
"A depend clause can only appear on the directive if the interop-type includes targetsync"_err_en_US);
56665660
}
56675661
}

0 commit comments

Comments
 (0)