From 06b551c944ff1cb4a21ca39c9e5ee6f67fc282ee Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 20 Aug 2022 21:18:27 -0700 Subject: [PATCH] Use llvm::is_contained (NFC) --- flang/include/flang/Lower/IterationSpace.h | 2 +- flang/lib/Lower/Bridge.cpp | 3 +-- flang/lib/Lower/ConvertVariable.cpp | 3 +-- flang/lib/Semantics/check-directive-structure.h | 4 +--- flang/lib/Semantics/check-omp-structure.cpp | 4 +--- flang/lib/Semantics/resolve-directives.cpp | 3 +-- flang/lib/Semantics/resolve-names-utils.cpp | 8 ++++---- flang/lib/Semantics/tools.cpp | 3 +-- llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 7 ++----- .../lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp | 8 +++----- 10 files changed, 16 insertions(+), 29 deletions(-) diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h index b2af504..82b77aa 100644 --- a/flang/include/flang/Lower/IterationSpace.h +++ b/flang/include/flang/Lower/IterationSpace.h @@ -565,7 +565,7 @@ template bool symbolSetsIntersect(llvm::ArrayRef ctrlSet, const A &exprSyms) { for (const auto &sym : exprSyms) - if (std::find(ctrlSet.begin(), ctrlSet.end(), &sym.get()) != ctrlSet.end()) + if (llvm::is_contained(ctrlSet, &sym.get())) return true; return false; } diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index 5217821..36348f9 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -1038,8 +1038,7 @@ private: for (Fortran::parser::Label label : std::get>(stmt.t)) { if (labelSet.count(label) && - std::find(indexList.begin(), indexList.end(), label) == - indexList.end()) { // ignore duplicates + !llvm::is_contained(indexList, label)) { // ignore duplicates addLabel(label); } } diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp index 013ebfd..abbe1f6 100644 --- a/flang/lib/Lower/ConvertVariable.cpp +++ b/flang/lib/Lower/ConvertVariable.cpp @@ -894,8 +894,7 @@ getCommonMembersWithInitAliases(const Fortran::semantics::Symbol &common) { if (!details->init() || com != &common) continue; // This is an alias with an init that belongs to the list - if (std::find(members.begin(), members.end(), obj.symbol) == - members.end()) + if (!llvm::is_contained(members, obj.symbol)) members.emplace_back(obj.symbol); } } diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h index 3fdcbf2..d1e7082 100644 --- a/flang/lib/Semantics/check-directive-structure.h +++ b/flang/lib/Semantics/check-directive-structure.h @@ -495,9 +495,7 @@ template void DirectiveStructureChecker::CheckNotAllowedIfClause(C clause, common::EnumSet set) { - if (std::find(GetContext().actualClauses.begin(), - GetContext().actualClauses.end(), - clause) == GetContext().actualClauses.end()) { + if (!llvm::is_contained(GetContext().actualClauses, clause)) { return; // Clause is not present } diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index 5b35150..dd18b9f 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -2275,9 +2275,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) { void OmpStructureChecker::CheckAllowedMapTypes( const parser::OmpMapType::Type &type, const std::list &allowedMapTypeList) { - const auto found{std::find( - std::begin(allowedMapTypeList), std::end(allowedMapTypeList), type)}; - if (found == std::end(allowedMapTypeList)) { + if (!llvm::is_contained(allowedMapTypeList, type)) { std::string commaSeperatedMapTypes; llvm::interleave( allowedMapTypeList.begin(), allowedMapTypeList.end(), diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index 21cb42e..5926dd0 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1881,8 +1881,7 @@ void OmpAttributeVisitor::CheckLabelContext(const parser::CharBlock source, bool OmpAttributeVisitor::HasSymbolInEnclosingScope( const Symbol &symbol, Scope &scope) { const auto symbols{scope.parent().GetSymbols()}; - auto it{std::find(symbols.begin(), symbols.end(), symbol)}; - return it != symbols.end(); + return llvm::is_contained(symbols, symbol); } } // namespace Fortran::semantics diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp index 7aab694..3b180df 100644 --- a/flang/lib/Semantics/resolve-names-utils.cpp +++ b/flang/lib/Semantics/resolve-names-utils.cpp @@ -55,13 +55,13 @@ bool IsIntrinsicOperator( std::string str{name.ToString()}; for (int i{0}; i != common::LogicalOperator_enumSize; ++i) { auto names{context.languageFeatures().GetNames(LogicalOperator{i})}; - if (std::find(names.begin(), names.end(), str) != names.end()) { + if (llvm::is_contained(names, str)) { return true; } } for (int i{0}; i != common::RelationalOperator_enumSize; ++i) { auto names{context.languageFeatures().GetNames(RelationalOperator{i})}; - if (std::find(names.begin(), names.end(), str) != names.end()) { + if (llvm::is_contained(names, str)) { return true; } } @@ -85,13 +85,13 @@ std::forward_list GetAllNames( name.ToString().rfind(std::string{operatorPrefix}, 0) == 0) { for (int i{0}; i != common::LogicalOperator_enumSize; ++i) { auto names{GetOperatorNames(context, LogicalOperator{i})}; - if (std::find(names.begin(), names.end(), str) != names.end()) { + if (llvm::is_contained(names, str)) { return names; } } for (int i{0}; i != common::RelationalOperator_enumSize; ++i) { auto names{GetOperatorNames(context, RelationalOperator{i})}; - if (std::find(names.begin(), names.end(), str) != names.end()) { + if (llvm::is_contained(names, str)) { return names; } } diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp index b977440..6f91024 100644 --- a/flang/lib/Semantics/tools.cpp +++ b/flang/lib/Semantics/tools.cpp @@ -217,8 +217,7 @@ std::string MakeOpName(SourceName name) { bool IsCommonBlockContaining(const Symbol &block, const Symbol &object) { const auto &objects{block.get().objects()}; - auto found{std::find(objects.begin(), objects.end(), object)}; - return found != objects.end(); + return llvm::is_contained(objects, object); } bool IsUseAssociated(const Symbol &symbol, const Scope &scope) { diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 52fcd22..1cb6158 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -676,11 +676,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST) // to be the same size as the dest. if (DstTy != SrcTy) return false; - for (auto &Ty : {v2s32, v4s32, v2s64, v2p0, v16s8, v8s16}) { - if (DstTy == Ty) - return true; - } - return false; + return llvm::is_contained({v2s32, v4s32, v2s64, v2p0, v16s8, v8s16}, + DstTy); }) // G_SHUFFLE_VECTOR can have scalar sources (from 1 x s vectors), we // just want those lowered into G_BUILD_VECTOR diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp index f78b6f0..0d5c7ef 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp @@ -34,11 +34,9 @@ using namespace mlir::sparse_tensor; // Helper to detect a sparse tensor type operand. static bool isSparseTensor(OpOperand *op) { if (auto enc = getSparseTensorEncoding(op->get().getType())) { - ArrayRef dimTypes = - enc.getDimLevelType(); - for (auto dimType : dimTypes) - if (dimType == SparseTensorEncodingAttr::DimLevelType::Compressed) - return true; // at least one compressed + if (llvm::is_contained(enc.getDimLevelType(), + SparseTensorEncodingAttr::DimLevelType::Compressed)) + return true; } return false; } -- 2.7.4