summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-29 21:23:30 +0000
committerChris Lattner <sabre@nondot.org>2002-04-29 21:23:30 +0000
commitf3dee03ba94b9fc0344db8c9da131211799d9f8a (patch)
treee43476b2f2b083e33f0b5e8eede1fc90a72a9cf5
parentaa261937c014b12349621f411a3b57c2eceb296a (diff)
downloadbcm5719-llvm-f3dee03ba94b9fc0344db8c9da131211799d9f8a.tar.gz
bcm5719-llvm-f3dee03ba94b9fc0344db8c9da131211799d9f8a.zip
Make the range insert operation return an iterator, even though the STL
range insert doesn't llvm-svn: 2413
-rw-r--r--llvm/include/llvm/ValueHolder.h8
-rw-r--r--llvm/lib/VMCore/ValueHolderImpl.h14
2 files changed, 15 insertions, 7 deletions
diff --git a/llvm/include/llvm/ValueHolder.h b/llvm/include/llvm/ValueHolder.h
index af08212b015..a69c7b60717 100644
--- a/llvm/include/llvm/ValueHolder.h
+++ b/llvm/include/llvm/ValueHolder.h
@@ -118,14 +118,14 @@ public:
iterator insert(iterator Pos, ValueSubclass *Inst);
// ValueHolder::insert - This method inserts the specified _range_ of values
- // before the 'Pos' iterator. This currently only works for vector
- // iterators...
+ // before the 'Pos' iterator, returning a new iterator that points to the
+ // first item inserted. *This currently only works for vector iterators...*
//
// FIXME: This is not generic so that the code does not have to be around
// to be used... is this ok?
//
- void insert(iterator Pos, // Where to insert
- iterator First, iterator Last); // Vector to read insts from
+ iterator insert(iterator Pos, // Where to insert
+ iterator First, iterator Last); // Vector to read insts from
};
#endif
diff --git a/llvm/lib/VMCore/ValueHolderImpl.h b/llvm/lib/VMCore/ValueHolderImpl.h
index cbc3e5f5588..3eb7e754569 100644
--- a/llvm/lib/VMCore/ValueHolderImpl.h
+++ b/llvm/lib/VMCore/ValueHolderImpl.h
@@ -172,12 +172,18 @@ ValueHolder<ValueSubclass,ItemParentType,SymTabType>
// to be used... is this ok?
//
template<class ValueSubclass, class ItemParentType, class SymTabType>
-void ValueHolder<ValueSubclass,ItemParentType,SymTabType>
-::insert(iterator Pos, // Where to insert
+ValueHolder<ValueSubclass,ItemParentType,SymTabType>::iterator
+ValueHolder<ValueSubclass,ItemParentType,SymTabType>
+::insert(iterator Pos, // Where to insert
iterator First, iterator Last) { // Vector to read insts from
+ // Since the vector range insert operation doesn't return an updated iterator,
+ // we have to convert the iterator to and index and back to assure that it
+ // cannot get invalidated. Gross hack, but effective.
+ //
+ unsigned Offset = Pos-begin();
+
// Check to make sure that the values are not already in some valueholder...
-
for (iterator X = First; X != Last; ++X) {
assert((*X)->getParent() == 0 &&
"Cannot insert into valueholder, value already has a parent!");
@@ -192,6 +198,8 @@ void ValueHolder<ValueSubclass,ItemParentType,SymTabType>
for (;First != Last; ++First)
if ((*First)->hasName())
Parent->getSymbolTableSure()->insert(*First);
+
+ return begin()+Offset;
}
#endif
OpenPOWER on IntegriCloud