[flang-commits] [flang] 8470cdd - [flang] Use llvm::any_of and llvm::none_of (NFC) (#102797)
via flang-commits
flang-commits at lists.llvm.org
Mon Aug 12 10:24:21 PDT 2024
Author: Kazu Hirata
Date: 2024-08-12T10:24:18-07:00
New Revision: 8470cdd499904093ba4faeff870fee12a3e80ff3
URL: https://github.com/llvm/llvm-project/commit/8470cdd499904093ba4faeff870fee12a3e80ff3
DIFF: https://github.com/llvm/llvm-project/commit/8470cdd499904093ba4faeff870fee12a3e80ff3.diff
LOG: [flang] Use llvm::any_of and llvm::none_of (NFC) (#102797)
Added:
Modified:
flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp
flang/lib/Semantics/data-to-inits.cpp
flang/lib/Semantics/rewrite-directives.cpp
flang/lib/Semantics/symbol.cpp
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp b/flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp
index 7d0b8b3d7bc53d..1e44288c784c2a 100644
--- a/flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp
+++ b/flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp
@@ -98,9 +98,8 @@ class CallOpRewriter : public mlir::OpRewritePattern<fir::CallOp> {
assert(!builder.getNamedGlobal(globalName) &&
"We should have a unique name here");
- if (std::find_if(allocas.begin(), allocas.end(), [alloca](auto x) {
- return x.first == alloca;
- }) == allocas.end()) {
+ if (llvm::none_of(allocas,
+ [alloca](auto x) { return x.first == alloca; })) {
allocas.push_back(std::make_pair(alloca, store));
}
diff --git a/flang/lib/Semantics/data-to-inits.cpp b/flang/lib/Semantics/data-to-inits.cpp
index b6dbbbf63138ec..0f8b36de460865 100644
--- a/flang/lib/Semantics/data-to-inits.cpp
+++ b/flang/lib/Semantics/data-to-inits.cpp
@@ -522,11 +522,10 @@ static const DerivedTypeSpec *HasDefaultInitialization(const Symbol &symbol) {
} else if (!object->isDummy() && object->type()) {
if (const DerivedTypeSpec * derived{object->type()->AsDerived()}) {
DirectComponentIterator directs{*derived};
- if (std::find_if(
- directs.begin(), directs.end(), [](const Symbol &component) {
- return !IsAllocatable(component) &&
- HasDeclarationInitializer(component);
- }) != directs.end()) {
+ if (llvm::any_of(directs, [](const Symbol &component) {
+ return !IsAllocatable(component) &&
+ HasDeclarationInitializer(component);
+ })) {
return derived;
}
}
diff --git a/flang/lib/Semantics/rewrite-directives.cpp b/flang/lib/Semantics/rewrite-directives.cpp
index 2c3c87f2546a35..c94d0f3855bee3 100644
--- a/flang/lib/Semantics/rewrite-directives.cpp
+++ b/flang/lib/Semantics/rewrite-directives.cpp
@@ -88,11 +88,9 @@ bool OmpRewriteMutator::Pre(parser::OpenMPAtomicConstruct &x) {
auto findMemOrderClause =
[](const std::list<parser::OmpAtomicClause> &clauses) {
- return std::find_if(
- clauses.begin(), clauses.end(), [](const auto &clause) {
- return std::get_if<parser::OmpMemoryOrderClause>(
- &clause.u);
- }) != clauses.end();
+ return llvm::any_of(clauses, [](const auto &clause) {
+ return std::get_if<parser::OmpMemoryOrderClause>(&clause.u);
+ });
};
// Get the clause list to which the new memory order clause must be added,
diff --git a/flang/lib/Semantics/symbol.cpp b/flang/lib/Semantics/symbol.cpp
index 31e91ee7355e33..b593bf89b18bc9 100644
--- a/flang/lib/Semantics/symbol.cpp
+++ b/flang/lib/Semantics/symbol.cpp
@@ -230,11 +230,10 @@ void GenericDetails::CopyFrom(const GenericDetails &from) {
derivedType_ = from.derivedType_;
}
for (std::size_t i{0}; i < from.specificProcs_.size(); ++i) {
- if (std::find_if(specificProcs_.begin(), specificProcs_.end(),
- [&](const Symbol &mySymbol) {
- return &mySymbol.GetUltimate() ==
- &from.specificProcs_[i]->GetUltimate();
- }) == specificProcs_.end()) {
+ if (llvm::none_of(specificProcs_, [&](const Symbol &mySymbol) {
+ return &mySymbol.GetUltimate() ==
+ &from.specificProcs_[i]->GetUltimate();
+ })) {
specificProcs_.push_back(from.specificProcs_[i]);
bindingNames_.push_back(from.bindingNames_[i]);
}
More information about the flang-commits
mailing list