Skip to content

Commit 8470cdd

Browse files
[flang] Use llvm::any_of and llvm::none_of (NFC) (#102797)
1 parent 5629249 commit 8470cdd

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ class CallOpRewriter : public mlir::OpRewritePattern<fir::CallOp> {
9898
assert(!builder.getNamedGlobal(globalName) &&
9999
"We should have a unique name here");
100100

101-
if (std::find_if(allocas.begin(), allocas.end(), [alloca](auto x) {
102-
return x.first == alloca;
103-
}) == allocas.end()) {
101+
if (llvm::none_of(allocas,
102+
[alloca](auto x) { return x.first == alloca; })) {
104103
allocas.push_back(std::make_pair(alloca, store));
105104
}
106105

flang/lib/Semantics/data-to-inits.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,10 @@ static const DerivedTypeSpec *HasDefaultInitialization(const Symbol &symbol) {
522522
} else if (!object->isDummy() && object->type()) {
523523
if (const DerivedTypeSpec * derived{object->type()->AsDerived()}) {
524524
DirectComponentIterator directs{*derived};
525-
if (std::find_if(
526-
directs.begin(), directs.end(), [](const Symbol &component) {
527-
return !IsAllocatable(component) &&
528-
HasDeclarationInitializer(component);
529-
}) != directs.end()) {
525+
if (llvm::any_of(directs, [](const Symbol &component) {
526+
return !IsAllocatable(component) &&
527+
HasDeclarationInitializer(component);
528+
})) {
530529
return derived;
531530
}
532531
}

flang/lib/Semantics/rewrite-directives.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ bool OmpRewriteMutator::Pre(parser::OpenMPAtomicConstruct &x) {
8888

8989
auto findMemOrderClause =
9090
[](const std::list<parser::OmpAtomicClause> &clauses) {
91-
return std::find_if(
92-
clauses.begin(), clauses.end(), [](const auto &clause) {
93-
return std::get_if<parser::OmpMemoryOrderClause>(
94-
&clause.u);
95-
}) != clauses.end();
91+
return llvm::any_of(clauses, [](const auto &clause) {
92+
return std::get_if<parser::OmpMemoryOrderClause>(&clause.u);
93+
});
9694
};
9795

9896
// Get the clause list to which the new memory order clause must be added,

flang/lib/Semantics/symbol.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,10 @@ void GenericDetails::CopyFrom(const GenericDetails &from) {
230230
derivedType_ = from.derivedType_;
231231
}
232232
for (std::size_t i{0}; i < from.specificProcs_.size(); ++i) {
233-
if (std::find_if(specificProcs_.begin(), specificProcs_.end(),
234-
[&](const Symbol &mySymbol) {
235-
return &mySymbol.GetUltimate() ==
236-
&from.specificProcs_[i]->GetUltimate();
237-
}) == specificProcs_.end()) {
233+
if (llvm::none_of(specificProcs_, [&](const Symbol &mySymbol) {
234+
return &mySymbol.GetUltimate() ==
235+
&from.specificProcs_[i]->GetUltimate();
236+
})) {
238237
specificProcs_.push_back(from.specificProcs_[i]);
239238
bindingNames_.push_back(from.bindingNames_[i]);
240239
}

0 commit comments

Comments
 (0)