Use llvm::is_contained (NFC)

This commit is contained in:
Kazu Hirata 2022-08-20 21:18:27 -07:00
parent 6b1bc80188
commit 06b551c944
10 changed files with 16 additions and 29 deletions

View File

@ -565,7 +565,7 @@ template <typename A>
bool symbolSetsIntersect(llvm::ArrayRef<FrontEndSymbol> ctrlSet, bool symbolSetsIntersect(llvm::ArrayRef<FrontEndSymbol> ctrlSet,
const A &exprSyms) { const A &exprSyms) {
for (const auto &sym : 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 true;
return false; return false;
} }

View File

@ -1038,8 +1038,7 @@ private:
for (Fortran::parser::Label label : for (Fortran::parser::Label label :
std::get<std::list<Fortran::parser::Label>>(stmt.t)) { std::get<std::list<Fortran::parser::Label>>(stmt.t)) {
if (labelSet.count(label) && if (labelSet.count(label) &&
std::find(indexList.begin(), indexList.end(), label) == !llvm::is_contained(indexList, label)) { // ignore duplicates
indexList.end()) { // ignore duplicates
addLabel(label); addLabel(label);
} }
} }

View File

@ -894,8 +894,7 @@ getCommonMembersWithInitAliases(const Fortran::semantics::Symbol &common) {
if (!details->init() || com != &common) if (!details->init() || com != &common)
continue; continue;
// This is an alias with an init that belongs to the list // This is an alias with an init that belongs to the list
if (std::find(members.begin(), members.end(), obj.symbol) == if (!llvm::is_contained(members, obj.symbol))
members.end())
members.emplace_back(obj.symbol); members.emplace_back(obj.symbol);
} }
} }

View File

@ -495,9 +495,7 @@ template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
void DirectiveStructureChecker<D, C, PC, void DirectiveStructureChecker<D, C, PC,
ClauseEnumSize>::CheckNotAllowedIfClause(C clause, ClauseEnumSize>::CheckNotAllowedIfClause(C clause,
common::EnumSet<C, ClauseEnumSize> set) { common::EnumSet<C, ClauseEnumSize> set) {
if (std::find(GetContext().actualClauses.begin(), if (!llvm::is_contained(GetContext().actualClauses, clause)) {
GetContext().actualClauses.end(),
clause) == GetContext().actualClauses.end()) {
return; // Clause is not present return; // Clause is not present
} }

View File

@ -2275,9 +2275,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) {
void OmpStructureChecker::CheckAllowedMapTypes( void OmpStructureChecker::CheckAllowedMapTypes(
const parser::OmpMapType::Type &type, const parser::OmpMapType::Type &type,
const std::list<parser::OmpMapType::Type> &allowedMapTypeList) { const std::list<parser::OmpMapType::Type> &allowedMapTypeList) {
const auto found{std::find( if (!llvm::is_contained(allowedMapTypeList, type)) {
std::begin(allowedMapTypeList), std::end(allowedMapTypeList), type)};
if (found == std::end(allowedMapTypeList)) {
std::string commaSeperatedMapTypes; std::string commaSeperatedMapTypes;
llvm::interleave( llvm::interleave(
allowedMapTypeList.begin(), allowedMapTypeList.end(), allowedMapTypeList.begin(), allowedMapTypeList.end(),

View File

@ -1881,8 +1881,7 @@ void OmpAttributeVisitor::CheckLabelContext(const parser::CharBlock source,
bool OmpAttributeVisitor::HasSymbolInEnclosingScope( bool OmpAttributeVisitor::HasSymbolInEnclosingScope(
const Symbol &symbol, Scope &scope) { const Symbol &symbol, Scope &scope) {
const auto symbols{scope.parent().GetSymbols()}; const auto symbols{scope.parent().GetSymbols()};
auto it{std::find(symbols.begin(), symbols.end(), symbol)}; return llvm::is_contained(symbols, symbol);
return it != symbols.end();
} }
} // namespace Fortran::semantics } // namespace Fortran::semantics

View File

@ -55,13 +55,13 @@ bool IsIntrinsicOperator(
std::string str{name.ToString()}; std::string str{name.ToString()};
for (int i{0}; i != common::LogicalOperator_enumSize; ++i) { for (int i{0}; i != common::LogicalOperator_enumSize; ++i) {
auto names{context.languageFeatures().GetNames(LogicalOperator{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; return true;
} }
} }
for (int i{0}; i != common::RelationalOperator_enumSize; ++i) { for (int i{0}; i != common::RelationalOperator_enumSize; ++i) {
auto names{context.languageFeatures().GetNames(RelationalOperator{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; return true;
} }
} }
@ -85,13 +85,13 @@ std::forward_list<std::string> GetAllNames(
name.ToString().rfind(std::string{operatorPrefix}, 0) == 0) { name.ToString().rfind(std::string{operatorPrefix}, 0) == 0) {
for (int i{0}; i != common::LogicalOperator_enumSize; ++i) { for (int i{0}; i != common::LogicalOperator_enumSize; ++i) {
auto names{GetOperatorNames(context, LogicalOperator{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; return names;
} }
} }
for (int i{0}; i != common::RelationalOperator_enumSize; ++i) { for (int i{0}; i != common::RelationalOperator_enumSize; ++i) {
auto names{GetOperatorNames(context, RelationalOperator{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; return names;
} }
} }

View File

@ -217,8 +217,7 @@ std::string MakeOpName(SourceName name) {
bool IsCommonBlockContaining(const Symbol &block, const Symbol &object) { bool IsCommonBlockContaining(const Symbol &block, const Symbol &object) {
const auto &objects{block.get<CommonBlockDetails>().objects()}; const auto &objects{block.get<CommonBlockDetails>().objects()};
auto found{std::find(objects.begin(), objects.end(), object)}; return llvm::is_contained(objects, object);
return found != objects.end();
} }
bool IsUseAssociated(const Symbol &symbol, const Scope &scope) { bool IsUseAssociated(const Symbol &symbol, const Scope &scope) {

View File

@ -676,11 +676,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
// to be the same size as the dest. // to be the same size as the dest.
if (DstTy != SrcTy) if (DstTy != SrcTy)
return false; return false;
for (auto &Ty : {v2s32, v4s32, v2s64, v2p0, v16s8, v8s16}) { return llvm::is_contained({v2s32, v4s32, v2s64, v2p0, v16s8, v8s16},
if (DstTy == Ty) DstTy);
return true;
}
return false;
}) })
// G_SHUFFLE_VECTOR can have scalar sources (from 1 x s vectors), we // G_SHUFFLE_VECTOR can have scalar sources (from 1 x s vectors), we
// just want those lowered into G_BUILD_VECTOR // just want those lowered into G_BUILD_VECTOR

View File

@ -34,11 +34,9 @@ using namespace mlir::sparse_tensor;
// Helper to detect a sparse tensor type operand. // Helper to detect a sparse tensor type operand.
static bool isSparseTensor(OpOperand *op) { static bool isSparseTensor(OpOperand *op) {
if (auto enc = getSparseTensorEncoding(op->get().getType())) { if (auto enc = getSparseTensorEncoding(op->get().getType())) {
ArrayRef<SparseTensorEncodingAttr::DimLevelType> dimTypes = if (llvm::is_contained(enc.getDimLevelType(),
enc.getDimLevelType(); SparseTensorEncodingAttr::DimLevelType::Compressed))
for (auto dimType : dimTypes) return true;
if (dimType == SparseTensorEncodingAttr::DimLevelType::Compressed)
return true; // at least one compressed
} }
return false; return false;
} }