[cfe-commits] r113799 - /cfe/trunk/include/clang/Analysis/Support/BumpVector.h
Ted Kremenek
kremenek at apple.com
Mon Sep 13 15:25:59 PDT 2010
Author: kremenek
Date: Mon Sep 13 17:25:59 2010
New Revision: 113799
URL: http://llvm.org/viewvc/llvm-project?rev=113799&view=rev
Log:
Add 'insert()' to BumpVector. Patch by Marcin Ĺwiderski!
Modified:
cfe/trunk/include/clang/Analysis/Support/BumpVector.h
Modified: cfe/trunk/include/clang/Analysis/Support/BumpVector.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Support/BumpVector.h?rev=113799&r1=113798&r2=113799&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Support/BumpVector.h (original)
+++ cfe/trunk/include/clang/Analysis/Support/BumpVector.h Mon Sep 13 17:25:59 2010
@@ -155,7 +155,25 @@
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 @@
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.
More information about the cfe-commits
mailing list