From: Sanjoy Das Date: Tue, 1 Dec 2015 07:49:27 +0000 (+0000) Subject: Introduce a range version of std::find, and use in SCEV X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=94214379c485ff7c89cf49c4c56aca8ec790ec4a;p=oota-llvm.git Introduce a range version of std::find, and use in SCEV Reviewers: dblaikie, pcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15064 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254391 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 3655a20d883..d4360fa8d21 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -379,6 +379,13 @@ bool any_of(R &&Range, UnaryPredicate &&P) { std::forward(P)); } +/// Provide wrappers to std::find which take ranges instead of having to pass +/// begin/end explicitly. +template +auto find(R &&Range, const T &val) -> decltype(Range.begin()) { + return std::find(Range.begin(), Range.end(), val); +} + //===----------------------------------------------------------------------===// // Extra additions to //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 4c8b6e7de84..d04028b15e2 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -7964,8 +7964,7 @@ static bool IsMaxConsistingOf(const SCEV *MaybeMaxExpr, const MaxExprType *MaxExpr = dyn_cast(MaybeMaxExpr); if (!MaxExpr) return false; - auto It = std::find(MaxExpr->op_begin(), MaxExpr->op_end(), Candidate); - return It != MaxExpr->op_end(); + return find(MaxExpr->operands(), Candidate) != MaxExpr->op_end(); }