[flang-commits] [flang] c282d79 - [flang][OpenMP] Use range-for to iterate over SymbolSourceMap, NFC
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Wed Dec 4 10:52:45 PST 2024
Author: Krzysztof Parzyszek
Date: 2024-12-04T12:52:34-06:00
New Revision: c282d790243cf56e3ac8487b1b47430673957112
URL: https://github.com/llvm/llvm-project/commit/c282d790243cf56e3ac8487b1b47430673957112
DIFF: https://github.com/llvm/llvm-project/commit/c282d790243cf56e3ac8487b1b47430673957112.diff
LOG: [flang][OpenMP] Use range-for to iterate over SymbolSourceMap, NFC
Avoid iterators, use structured bindings to unpack the [key, value]
pairs.
Added:
Modified:
flang/lib/Semantics/check-omp-structure.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 56ec7a0ad2d869..f09542e5b5df14 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2765,9 +2765,9 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
if (const parser::OmpObjectList *objList{GetOmpObjectList(x)}) {
SymbolSourceMap symbols;
GetSymbolsInObjectList(*objList, symbols);
- for (const auto &[sym, source] : symbols) {
- if (!IsVariableListItem(*sym)) {
- deferredNonVariables_.insert({sym, source});
+ for (const auto &[symbol, source] : symbols) {
+ if (!IsVariableListItem(*symbol)) {
+ deferredNonVariables_.insert({symbol, source});
}
}
}
@@ -3878,9 +3878,7 @@ void OmpStructureChecker::CheckDoacross(const parser::OmpDoacross &doa) {
void OmpStructureChecker::CheckCopyingPolymorphicAllocatable(
SymbolSourceMap &symbols, const llvm::omp::Clause clause) {
if (context_.ShouldWarn(common::UsageWarning::Portability)) {
- for (auto it{symbols.begin()}; it != symbols.end(); ++it) {
- const auto *symbol{it->first};
- const auto source{it->second};
+ for (auto &[symbol, source] : symbols) {
if (IsPolymorphicAllocatable(*symbol)) {
context_.Warn(common::UsageWarning::Portability, source,
"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) {
const parser::OmpObjectList &objList{x.v};
SymbolSourceMap symbols;
GetSymbolsInObjectList(objList, symbols);
- for (const auto &[sym, source] : symbols) {
- if (!IsExtendedListItem(*sym)) {
- context_.SayWithDecl(*sym, source,
- "'%s' must be a variable or a procedure"_err_en_US, sym->name());
+ for (const auto &[symbol, source] : symbols) {
+ if (!IsExtendedListItem(*symbol)) {
+ context_.SayWithDecl(*symbol, source,
+ "'%s' must be a variable or a procedure"_err_en_US, symbol->name());
}
}
}
@@ -4146,10 +4144,10 @@ void OmpStructureChecker::Enter(const parser::OmpClause::From &x) {
const auto &objList{std::get<parser::OmpObjectList>(x.v.t)};
SymbolSourceMap symbols;
GetSymbolsInObjectList(objList, symbols);
- for (const auto &[sym, source] : symbols) {
- if (!IsVariableListItem(*sym)) {
+ for (const auto &[symbol, source] : symbols) {
+ if (!IsVariableListItem(*symbol)) {
context_.SayWithDecl(
- *sym, source, "'%s' must be a variable"_err_en_US, sym->name());
+ *symbol, source, "'%s' must be a variable"_err_en_US, symbol->name());
}
}
@@ -4191,10 +4189,10 @@ void OmpStructureChecker::Enter(const parser::OmpClause::To &x) {
const auto &objList{std::get<parser::OmpObjectList>(x.v.t)};
SymbolSourceMap symbols;
GetSymbolsInObjectList(objList, symbols);
- for (const auto &[sym, source] : symbols) {
- if (!IsVariableListItem(*sym)) {
+ for (const auto &[symbol, source] : symbols) {
+ if (!IsVariableListItem(*symbol)) {
context_.SayWithDecl(
- *sym, source, "'%s' must be a variable"_err_en_US, sym->name());
+ *symbol, source, "'%s' must be a variable"_err_en_US, symbol->name());
}
}
@@ -4291,9 +4289,7 @@ void OmpStructureChecker::CheckIntentInPointer(
const parser::OmpObjectList &objectList, const llvm::omp::Clause clause) {
SymbolSourceMap symbols;
GetSymbolsInObjectList(objectList, symbols);
- for (auto it{symbols.begin()}; it != symbols.end(); ++it) {
- const auto *symbol{it->first};
- const auto source{it->second};
+ for (auto &[symbol, source] : symbols) {
if (IsPointer(*symbol) && IsIntentIn(*symbol)) {
context_.Say(source,
"Pointer '%s' with the INTENT(IN) attribute may not appear "
@@ -4324,9 +4320,7 @@ void OmpStructureChecker::GetSymbolsInObjectList(
void OmpStructureChecker::CheckDefinableObjects(
SymbolSourceMap &symbols, const llvm::omp::Clause clause) {
- for (auto it{symbols.begin()}; it != symbols.end(); ++it) {
- const auto *symbol{it->first};
- const auto source{it->second};
+ for (auto &[symbol, source] : symbols) {
if (auto msg{WhyNotDefinable(source, context_.FindScope(source),
DefinabilityFlags{}, *symbol)}) {
context_
@@ -4358,9 +4352,7 @@ void OmpStructureChecker::CheckPrivateSymbolsInOuterCxt(
}
// Check if the symbols in current context are private in outer context
- for (auto iter{currSymbols.begin()}; iter != currSymbols.end(); ++iter) {
- const auto *symbol{iter->first};
- const auto source{iter->second};
+ for (auto &[symbol, source] : currSymbols) {
if (enclosingSymbols.find(symbol) != enclosingSymbols.end()) {
context_.Say(source,
"%s variable '%s' is PRIVATE in outer context"_err_en_US,
More information about the flang-commits
mailing list