Commit Graph

16 Commits

Author SHA1 Message Date
Chandler Carruth
5a88dda4be Sort the #include lines for unittest/...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169250 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 10:23:08 +00:00
Chandler Carruth
ba1f580f33 Move the SmallVector unit tests to be type-parameterized so that we can
test more than a single instantiation of SmallVector.

Add testing for 0, 1, 2, and 4 element sized "small" buffers. These
appear to be essentially untested in the unit tests until now.

Fix several tests to be robust in the face of a '0' small buffer. As
a consequence of this size buffer, the growth patterns are actually
observable in the test -- yes this means that many tests never caused
a grow to occur before. For some tests I've merely added a reserve call
to normalize behavior. For others, the growth is actually interesting,
and so I captured the fact that growth would occur and adjusted the
assertions to not assume how rapidly growth occured.

Also update the specialization for a '0' small buffer length to have all
the same interface points as the normal small vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161001 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 22:17:52 +00:00
Benjamin Kramer
d45f7b6b5d Bring the return value of SmallVector::insert in line with std::vector::insert.
It always returns the iterator for the first inserted element, or the passed in
iterator if the inserted range was empty. Flesh out the unit test more and fix
all the cases it uncovered so far.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158645 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-17 12:46:13 +00:00
Benjamin Kramer
5f6c7cfa93 SmallVector: return a valid iterator for the rare case of inserting an empty range into a SmallVector.
Patch by Johannes Schaub!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158643 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-17 11:52:22 +00:00
Benjamin Kramer
3703baacf5 SmallVector: Don't rely on having an assignment operator around in push_back for POD-like types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155791 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-29 10:53:29 +00:00
Chris Lattner
db125cfaf5 land David Blaikie's patch to de-constify Type, with a few tweaks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 04:54:35 +00:00
Owen Anderson
9cbd7afb76 Fix a subtle issue in SmallVector. The following code did not work as expected:
vec.insert(vec.begin(), vec[3]);
The issue was that vec[3] returns a reference into the vector, which is invalidated when insert() memmove's the elements down to make space.  The method needs to specifically detect and handle this case to correctly match std::vector's semantics.

Thanks to Howard Hinnant for clarifying the correct behavior, and explaining how std::vector solves this problem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134554 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 22:36:59 +00:00
Chandler Carruth
100c267249 Switch attribute macros to use 'LLVM_' as a prefix. We retain the old names
until other LLVM projects using these are cleaned up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117200 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-23 08:10:43 +00:00
Bill Wendling
d400850101 Silence 'unused' warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111539 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 18:52:02 +00:00
Dan Gohman
a7a33fd95f Fix SmallVector's insert to handle non-random-access iterators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99633 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26 18:53:37 +00:00
Dan Gohman
5ffc72e7ce Make this test more lenient; with SmallVector now using actually
aligned storage, the capacity may be more than what is explicitly
requested.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 18:47:50 +00:00
Daniel Dunbar
c2da6fb3e5 Add SmallVector::{capacity,set_size}.
- These allow clients to make use of the extra elements in the vector which
   have already been allocated, without requiring them to be value initialized.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79433 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 17:48:28 +00:00
Daniel Dunbar
614be08dd6 Clarify a FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-12 19:45:34 +00:00
Owen Anderson
3f7c72ab54 Use the testcase from PR2791.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 00:15:26 +00:00
Bill Wendling
3d9fbee0df Fix naming of file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62035 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 01:25:51 +00:00
Bill Wendling
f2850d9e27 Adding unittests for SmallVector. Test by Talin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-10 12:56:31 +00:00