From 360c1111e358c4c7e8591953ce9548d60c9410a6 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 20 Jul 2022 09:09:19 -0700 Subject: [PATCH] Use llvm::is_contained (NFC) --- lld/MachO/Driver.cpp | 3 +-- lldb/source/API/SBBreakpoint.cpp | 3 +-- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp | 8 ++------ lldb/source/Target/TargetList.cpp | 3 +-- llvm/lib/Support/CommandLine.cpp | 2 +- mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp | 5 ++--- mlir/lib/IR/AffineExpr.cpp | 2 +- polly/include/polly/ScopInfo.h | 3 +-- 8 files changed, 10 insertions(+), 19 deletions(-) diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index 63a0e7f..f5c4e82 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -503,8 +503,7 @@ static bool markReexport(StringRef searchName, ArrayRef extensions) { if (auto *dylibFile = dyn_cast(file)) { StringRef filename = path::filename(dylibFile->getName()); if (filename.consume_front(searchName) && - (filename.empty() || - find(extensions, filename) != extensions.end())) { + (filename.empty() || llvm::is_contained(extensions, filename))) { dylibFile->reexport = true; return true; } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 5fe8f7f..19b2a43 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -835,8 +835,7 @@ public: if (bkpt->GetTargetSP() != target_sp) return false; lldb::break_id_t bp_id = bkpt->GetID(); - if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) == - m_break_ids.end()) + if (!llvm::is_contained(m_break_ids, bp_id)) return false; m_break_ids.push_back(bkpt->GetID()); diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 579ac6e..4db7abe6 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -396,15 +396,11 @@ bool RegisterInfoPOSIX_arm64::IsSVERegVG(unsigned reg) const { } bool RegisterInfoPOSIX_arm64::IsPAuthReg(unsigned reg) const { - return std::find(pauth_regnum_collection.begin(), - pauth_regnum_collection.end(), - reg) != pauth_regnum_collection.end(); + return llvm::is_contained(pauth_regnum_collection, reg); } bool RegisterInfoPOSIX_arm64::IsMTEReg(unsigned reg) const { - return std::find(m_mte_regnum_collection.begin(), - m_mte_regnum_collection.end(), - reg) != m_mte_regnum_collection.end(); + return llvm::is_contained(m_mte_regnum_collection, reg); } uint32_t RegisterInfoPOSIX_arm64::GetRegNumSVEZ0() const { return sve_z0; } diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 214e98e..8290369 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -509,8 +509,7 @@ uint32_t TargetList::GetIndexOfTarget(lldb::TargetSP target_sp) const { } void TargetList::AddTargetInternal(TargetSP target_sp, bool do_select) { - lldbassert(std::find(m_target_list.begin(), m_target_list.end(), target_sp) == - m_target_list.end() && + lldbassert(!llvm::is_contained(m_target_list, target_sp) && "target already exists it the list"); m_target_list.push_back(std::move(target_sp)); if (do_select) diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index e3df172..5e7d631 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -2382,7 +2382,7 @@ protected: for (size_t I = 0, E = Opts.size(); I != E; ++I) { Option *Opt = Opts[I].second; for (auto &Cat : Opt->Categories) { - assert(find(SortedCategories, Cat) != SortedCategories.end() && + assert(llvm::is_contained(SortedCategories, Cat) && "Option has an unregistered category"); CategorizedOptions[Cat].push_back(Opt); } diff --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp index d5e8551..0147da8 100644 --- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp @@ -84,7 +84,7 @@ void IntegerRangeAnalysis::visitOperation( auto result = v.dyn_cast(); if (!result) return; - assert(llvm::find(op->getResults(), result) != op->result_end()); + assert(llvm::is_contained(op->getResults(), result)); LLVM_DEBUG(llvm::dbgs() << "Inferred range " << attrs << "\n"); IntegerValueRangeLattice *lattice = results[result.getResultNumber()]; @@ -126,8 +126,7 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments( auto arg = v.dyn_cast(); if (!arg) return; - if (llvm::find(successor.getSuccessor()->getArguments(), arg) == - successor.getSuccessor()->args_end()) + if (!llvm::is_contained(successor.getSuccessor()->getArguments(), arg)) return; LLVM_DEBUG(llvm::dbgs() << "Inferred range " << attrs << "\n"); diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp index 38d0e9b..4b553d8 100644 --- a/mlir/lib/IR/AffineExpr.cpp +++ b/mlir/lib/IR/AffineExpr.cpp @@ -974,7 +974,7 @@ static AffineExpr getSemiAffineExprFromFlatForm(ArrayRef flatExprs, // Adds entries to `indexToExprMap`, `coefficients` and `indices`. auto addEntry = [&](std::pair index, int64_t coefficient, AffineExpr expr) { - assert(std::find(indices.begin(), indices.end(), index) == indices.end() && + assert(!llvm::is_contained(indices, index) && "Key is already present in indices vector and overwriting will " "happen in `indexToExprMap` and `coefficients`!"); diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 404edc8..b89d1be 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1359,8 +1359,7 @@ public: if (!Inst) return false; if (isBlockStmt()) - return std::find(Instructions.begin(), Instructions.end(), Inst) != - Instructions.end(); + return llvm::is_contained(Instructions, Inst); return represents(Inst->getParent()); } -- 2.7.4