aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/Support/BumpVector.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-13 22:25:59 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-13 22:25:59 +0000
commit58eb45baff08fd27aeef65fc4e6ae35a4b3a1d90 (patch)
tree8eae412c0f6767976b7abcd72aeff6c055cd2dbe /include/clang/Analysis/Support/BumpVector.h
parentfe255bc6dfddade15644aecead970791e96ddedc (diff)
Add 'insert()' to BumpVector. Patch by Marcin Świderski!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/Support/BumpVector.h')
-rw-r--r--include/clang/Analysis/Support/BumpVector.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/include/clang/Analysis/Support/BumpVector.h b/include/clang/Analysis/Support/BumpVector.h
index 7cd481238f..020e858b9b 100644
--- a/include/clang/Analysis/Support/BumpVector.h
+++ b/include/clang/Analysis/Support/BumpVector.h
@@ -155,7 +155,25 @@ public:
grow(C);
goto Retry;
}
-
+
+ /// insert - Insert some number of copies of element into a position. Return
+ /// iterator to position after last inserted copy.
+ iterator insert(iterator I, size_t Cnt, const_reference E,
+ BumpVectorContext &C) {
+ assert (I >= Begin && I <= End && "Iterator out of bounds.");
+ if (End + Cnt <= Capacity) {
+ Retry:
+ move_range_right(I, End, Cnt);
+ construct_range(I, I + Cnt, E);
+ End += Cnt;
+ return I + Cnt;
+ }
+ ptrdiff_t D = I - Begin;
+ grow(C, size() + Cnt);
+ I = Begin + D;
+ goto Retry;
+ }
+
void reserve(BumpVectorContext &C, unsigned N) {
if (unsigned(Capacity-Begin) < N)
grow(C, N);
@@ -181,6 +199,14 @@ private:
E->~T();
}
}
+
+ void move_range_right(T *S, T *E, size_t D) {
+ for (T *I = E + D - 1, *IL = S + D - 1; I != IL; --I) {
+ --E;
+ new (I) T(*E);
+ E->~T();
+ }
+ }
};
// Define this out-of-line to dissuade the C++ compiler from inlining it.