llvm.org GIT mirror llvm / 75eac5f
Switch the SetVector::remove_if implementation to use partition which preserves the values of the relocated entries, unlikely remove_if. This allows walking them and erasing them. Also flesh out the predicate we are using for this to support the various constraints actually imposed on a UnaryPredicate -- without this we can't compose it with std::not1. Thanks to Sean Silva for the review here and noticing the issue with std::remove_if. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165073 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 7 years ago
2 changed file(s) with 6 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
140140 /// \returns true if any element is removed.
141141 template
142142 bool remove_if(UnaryPredicate P) {
143 typename vector_type::iterator B = std::remove_if(vector_.begin(),
144 vector_.end(), P),
143 typename vector_type::iterator B = std::partition(vector_.begin(),
144 vector_.end(),
145 std::not1(P)),
145146 E = vector_.end();
146147 if (B == E)
147148 return false;
32723272 const SetType &Set;
32733273
32743274 public:
3275 typedef AllocaInst *argument_type;
3276
32753277 IsAllocaInSet(const SetType &Set) : Set(Set) {}
3276 bool operator()(AllocaInst *AI) { return Set.count(AI); }
3278 bool operator()(AllocaInst *AI) const { return Set.count(AI); }
32773279 };
32783280 }
32793281