Skip to content

Commit c282d79

Browse files
committed
[flang][OpenMP] Use range-for to iterate over SymbolSourceMap, NFC
Avoid iterators, use structured bindings to unpack the [key, value] pairs.
1 parent 095c3c9 commit c282d79

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

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

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,9 +2765,9 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
27652765
if (const parser::OmpObjectList *objList{GetOmpObjectList(x)}) {
27662766
SymbolSourceMap symbols;
27672767
GetSymbolsInObjectList(*objList, symbols);
2768-
for (const auto &[sym, source] : symbols) {
2769-
if (!IsVariableListItem(*sym)) {
2770-
deferredNonVariables_.insert({sym, source});
2768+
for (const auto &[symbol, source] : symbols) {
2769+
if (!IsVariableListItem(*symbol)) {
2770+
deferredNonVariables_.insert({symbol, source});
27712771
}
27722772
}
27732773
}
@@ -3878,9 +3878,7 @@ void OmpStructureChecker::CheckDoacross(const parser::OmpDoacross &doa) {
38783878
void OmpStructureChecker::CheckCopyingPolymorphicAllocatable(
38793879
SymbolSourceMap &symbols, const llvm::omp::Clause clause) {
38803880
if (context_.ShouldWarn(common::UsageWarning::Portability)) {
3881-
for (auto it{symbols.begin()}; it != symbols.end(); ++it) {
3882-
const auto *symbol{it->first};
3883-
const auto source{it->second};
3881+
for (auto &[symbol, source] : symbols) {
38843882
if (IsPolymorphicAllocatable(*symbol)) {
38853883
context_.Warn(common::UsageWarning::Portability, source,
38863884
"If a polymorphic variable with allocatable attribute '%s' is in %s clause, the behavior is unspecified"_port_en_US,
@@ -4121,10 +4119,10 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Enter &x) {
41214119
const parser::OmpObjectList &objList{x.v};
41224120
SymbolSourceMap symbols;
41234121
GetSymbolsInObjectList(objList, symbols);
4124-
for (const auto &[sym, source] : symbols) {
4125-
if (!IsExtendedListItem(*sym)) {
4126-
context_.SayWithDecl(*sym, source,
4127-
"'%s' must be a variable or a procedure"_err_en_US, sym->name());
4122+
for (const auto &[symbol, source] : symbols) {
4123+
if (!IsExtendedListItem(*symbol)) {
4124+
context_.SayWithDecl(*symbol, source,
4125+
"'%s' must be a variable or a procedure"_err_en_US, symbol->name());
41284126
}
41294127
}
41304128
}
@@ -4146,10 +4144,10 @@ void OmpStructureChecker::Enter(const parser::OmpClause::From &x) {
41464144
const auto &objList{std::get<parser::OmpObjectList>(x.v.t)};
41474145
SymbolSourceMap symbols;
41484146
GetSymbolsInObjectList(objList, symbols);
4149-
for (const auto &[sym, source] : symbols) {
4150-
if (!IsVariableListItem(*sym)) {
4147+
for (const auto &[symbol, source] : symbols) {
4148+
if (!IsVariableListItem(*symbol)) {
41514149
context_.SayWithDecl(
4152-
*sym, source, "'%s' must be a variable"_err_en_US, sym->name());
4150+
*symbol, source, "'%s' must be a variable"_err_en_US, symbol->name());
41534151
}
41544152
}
41554153

@@ -4191,10 +4189,10 @@ void OmpStructureChecker::Enter(const parser::OmpClause::To &x) {
41914189
const auto &objList{std::get<parser::OmpObjectList>(x.v.t)};
41924190
SymbolSourceMap symbols;
41934191
GetSymbolsInObjectList(objList, symbols);
4194-
for (const auto &[sym, source] : symbols) {
4195-
if (!IsVariableListItem(*sym)) {
4192+
for (const auto &[symbol, source] : symbols) {
4193+
if (!IsVariableListItem(*symbol)) {
41964194
context_.SayWithDecl(
4197-
*sym, source, "'%s' must be a variable"_err_en_US, sym->name());
4195+
*symbol, source, "'%s' must be a variable"_err_en_US, symbol->name());
41984196
}
41994197
}
42004198

@@ -4291,9 +4289,7 @@ void OmpStructureChecker::CheckIntentInPointer(
42914289
const parser::OmpObjectList &objectList, const llvm::omp::Clause clause) {
42924290
SymbolSourceMap symbols;
42934291
GetSymbolsInObjectList(objectList, symbols);
4294-
for (auto it{symbols.begin()}; it != symbols.end(); ++it) {
4295-
const auto *symbol{it->first};
4296-
const auto source{it->second};
4292+
for (auto &[symbol, source] : symbols) {
42974293
if (IsPointer(*symbol) && IsIntentIn(*symbol)) {
42984294
context_.Say(source,
42994295
"Pointer '%s' with the INTENT(IN) attribute may not appear "
@@ -4324,9 +4320,7 @@ void OmpStructureChecker::GetSymbolsInObjectList(
43244320

43254321
void OmpStructureChecker::CheckDefinableObjects(
43264322
SymbolSourceMap &symbols, const llvm::omp::Clause clause) {
4327-
for (auto it{symbols.begin()}; it != symbols.end(); ++it) {
4328-
const auto *symbol{it->first};
4329-
const auto source{it->second};
4323+
for (auto &[symbol, source] : symbols) {
43304324
if (auto msg{WhyNotDefinable(source, context_.FindScope(source),
43314325
DefinabilityFlags{}, *symbol)}) {
43324326
context_
@@ -4358,9 +4352,7 @@ void OmpStructureChecker::CheckPrivateSymbolsInOuterCxt(
43584352
}
43594353

43604354
// Check if the symbols in current context are private in outer context
4361-
for (auto iter{currSymbols.begin()}; iter != currSymbols.end(); ++iter) {
4362-
const auto *symbol{iter->first};
4363-
const auto source{iter->second};
4355+
for (auto &[symbol, source] : currSymbols) {
43644356
if (enclosingSymbols.find(symbol) != enclosingSymbols.end()) {
43654357
context_.Say(source,
43664358
"%s variable '%s' is PRIVATE in outer context"_err_en_US,

0 commit comments

Comments
 (0)