mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool>
This is to be consistent with StringSet and ultimately with the standard library's associative container insert function. This lead to updating SmallSet::insert to return pair<iterator, bool>, and then to update SmallPtrSet::insert to return pair<iterator, bool>, and then to update all the existing users of those functions... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222334 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -57,7 +57,7 @@ public:
|
||||
// Return true if edge destination should be visited.
|
||||
template<typename NodeType>
|
||||
bool insertEdge(NodeType *From, NodeType *To) {
|
||||
return Visited.insert(To);
|
||||
return Visited.insert(To).second;
|
||||
}
|
||||
|
||||
// Called after all children of BB have been visited.
|
||||
|
@@ -100,7 +100,7 @@ public:
|
||||
/// \brief Insert a new element into the SetVector.
|
||||
/// \returns true iff the element was inserted into the SetVector.
|
||||
bool insert(const value_type &X) {
|
||||
bool result = set_.insert(X);
|
||||
bool result = set_.insert(X).second;
|
||||
if (result)
|
||||
vector_.push_back(X);
|
||||
return result;
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
template<typename It>
|
||||
void insert(It Start, It End) {
|
||||
for (; Start != End; ++Start)
|
||||
if (set_.insert(*Start))
|
||||
if (set_.insert(*Start).second)
|
||||
vector_.push_back(*Start);
|
||||
}
|
||||
|
||||
|
@@ -100,7 +100,7 @@ protected:
|
||||
/// insert_imp - This returns true if the pointer was new to the set, false if
|
||||
/// it was already in the set. This is hidden from the client so that the
|
||||
/// derived class can check that the right type of pointer is passed in.
|
||||
bool insert_imp(const void * Ptr);
|
||||
std::pair<const void *const *, bool> insert_imp(const void *Ptr);
|
||||
|
||||
/// erase_imp - If the set contains the specified pointer, remove it and
|
||||
/// return true, otherwise return false. This is hidden from the client so
|
||||
@@ -253,10 +253,14 @@ protected:
|
||||
: SmallPtrSetImplBase(SmallStorage, SmallSize) {}
|
||||
|
||||
public:
|
||||
typedef SmallPtrSetIterator<PtrType> iterator;
|
||||
typedef SmallPtrSetIterator<PtrType> const_iterator;
|
||||
|
||||
/// insert - This returns true if the pointer was new to the set, false if it
|
||||
/// was already in the set.
|
||||
bool insert(PtrType Ptr) {
|
||||
return insert_imp(PtrTraits::getAsVoidPointer(Ptr));
|
||||
std::pair<iterator, bool> insert(PtrType Ptr) {
|
||||
auto p = insert_imp(PtrTraits::getAsVoidPointer(Ptr));
|
||||
return std::make_pair(iterator(p.first, CurArray + CurArraySize), p.second);
|
||||
}
|
||||
|
||||
/// erase - If the set contains the specified pointer, remove it and return
|
||||
@@ -276,8 +280,6 @@ public:
|
||||
insert(*I);
|
||||
}
|
||||
|
||||
typedef SmallPtrSetIterator<PtrType> iterator;
|
||||
typedef SmallPtrSetIterator<PtrType> const_iterator;
|
||||
inline iterator begin() const {
|
||||
return iterator(CurArray, CurArray+CurArraySize);
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#ifndef LLVM_ADT_SMALLSET_H
|
||||
#define LLVM_ADT_SMALLSET_H
|
||||
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include <set>
|
||||
@@ -60,16 +61,21 @@ public:
|
||||
|
||||
/// insert - Insert an element into the set if it isn't already there.
|
||||
/// Returns true if the element is inserted (it was not in the set before).
|
||||
bool insert(const T &V) {
|
||||
/// The first value of the returned pair is unused and provided for
|
||||
/// partial compatibility with the standard library self-associative container
|
||||
/// concept.
|
||||
// FIXME: Add iterators that abstract over the small and large form, and then
|
||||
// return those here.
|
||||
std::pair<NoneType, bool> insert(const T &V) {
|
||||
if (!isSmall())
|
||||
return Set.insert(V).second;
|
||||
return std::make_pair(None, Set.insert(V).second);
|
||||
|
||||
VIterator I = vfind(V);
|
||||
if (I != Vector.end()) // Don't reinsert if it already exists.
|
||||
return false;
|
||||
return std::make_pair(None, false);
|
||||
if (Vector.size() < N) {
|
||||
Vector.push_back(V);
|
||||
return true;
|
||||
return std::make_pair(None, true);
|
||||
}
|
||||
|
||||
// Otherwise, grow from vector to set.
|
||||
@@ -78,7 +84,7 @@ public:
|
||||
Vector.pop_back();
|
||||
}
|
||||
Set.insert(V);
|
||||
return true;
|
||||
return std::make_pair(None, true);
|
||||
}
|
||||
|
||||
template <typename IterT>
|
||||
|
@@ -172,7 +172,7 @@ ForwardDominanceFrontierBase<BlockT>::calculate(const DomTreeT &DT,
|
||||
DomSetType &S = this->Frontiers[currentBB];
|
||||
|
||||
// Visit each block only once.
|
||||
if (visited.insert(currentBB)) {
|
||||
if (visited.insert(currentBB).second) {
|
||||
// Loop over CFG successors to calculate DFlocal[currentNode]
|
||||
for (auto SI = BlockTraits::child_begin(currentBB),
|
||||
SE = BlockTraits::child_end(currentBB);
|
||||
|
@@ -577,7 +577,7 @@ namespace llvm {
|
||||
SmallPtrSet<const SCEV *, 8> Visited;
|
||||
|
||||
void push(const SCEV *S) {
|
||||
if (Visited.insert(S) && Visitor.follow(S))
|
||||
if (Visited.insert(S).second && Visitor.follow(S))
|
||||
Worklist.push_back(S);
|
||||
}
|
||||
public:
|
||||
|
@@ -303,7 +303,7 @@ public:
|
||||
void recordSplitCriticalEdge(MachineBasicBlock *FromBB,
|
||||
MachineBasicBlock *ToBB,
|
||||
MachineBasicBlock *NewBB) {
|
||||
bool Inserted = NewBBs.insert(NewBB);
|
||||
bool Inserted = NewBBs.insert(NewBB).second;
|
||||
(void)Inserted;
|
||||
assert(Inserted &&
|
||||
"A basic block inserted via edge splitting cannot appear twice");
|
||||
|
@@ -125,7 +125,7 @@ Eval(DominatorTreeBase<typename GraphT::NodeType>& DT,
|
||||
typename GraphT::NodeType* VAncestor = DT.Vertex[VInfo.Parent];
|
||||
|
||||
// Process Ancestor first
|
||||
if (Visited.insert(VAncestor) && VInfo.Parent >= LastLinked) {
|
||||
if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) {
|
||||
Work.push_back(VAncestor);
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user