bool symbolSetsIntersect(llvm::ArrayRef<FrontEndSymbol> 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;
}
for (Fortran::parser::Label label :
std::get<std::list<Fortran::parser::Label>>(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);
}
}
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);
}
}
void DirectiveStructureChecker<D, C, PC,
ClauseEnumSize>::CheckNotAllowedIfClause(C clause,
common::EnumSet<C, ClauseEnumSize> 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
}
void OmpStructureChecker::CheckAllowedMapTypes(
const parser::OmpMapType::Type &type,
const std::list<parser::OmpMapType::Type> &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(),
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
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;
}
}
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;
}
}
bool IsCommonBlockContaining(const Symbol &block, const Symbol &object) {
const auto &objects{block.get<CommonBlockDetails>().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) {
// 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
// Helper to detect a sparse tensor type operand.
static bool isSparseTensor(OpOperand *op) {
if (auto enc = getSparseTensorEncoding(op->get().getType())) {
- ArrayRef<SparseTensorEncodingAttr::DimLevelType> 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;
}