Commit Graph

66 Commits

Author SHA1 Message Date
Gabor Greif
f0891be8bd Clean up the minor mess I caused with removing iterator.h. I shall take care of 80-col violations and the FIXME later. (Thanks goodness that I live in another continent, so the monkeypox did not strike me :-)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80224 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 06:41:46 +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
Jay Foad
c5d73afa48 Tighten up the asserts in SmallVector::operator[]().
If this causes any new assertion failures that I didn't catch in
testing, the fix is usually to change "&v[0]" to "v.data()" for some
SmallVector v.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72221 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 19:48:58 +00:00
Jay Foad
82fe2935bf Implement new SmallVector::data() methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 09:00:37 +00:00
Owen Anderson
747972914a Fix for PR3946, in which SmallVector could behave strangely in corner cases.
Patch by Peter Johnson.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69785 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 07:16:54 +00:00
Chris Lattner
d0dfbe096d fix overflow checks in SmallVector:
"The code was doing "if (End+NumInputs > Capacity) ...". If End is
close to 0xFFFFFFFF and NumInputs is large, it'll overflow, the
condition will come out false, and the vector won't grow to
accommodate the new elements, and the program will crash in memmove."

Patch by Jeffrey Yasskin!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68277 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 03:06:26 +00:00
Chris Lattner
dae2206390 Fix PR3860 by correcting a predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67473 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-22 19:22:53 +00:00
Misha Brukman
a2769a33c9 Fixed lint errors:
* Alphabetized #includes
* Removed trailing whitespace
* Wrapped or shortened lines over 80 chars


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 22:20:18 +00:00
Dan Gohman
38deef9ce5 Add explicit keywords.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64915 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 16:37:45 +00:00
Misha Brukman
3a54b3dc87 Removed trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 19:25:42 +00:00
Cedric Venet
c1edbfc2ba Add explicit this-> for some member function in templated base class.
These call are probably dependent but VS with /Za don't seems to think so. We need to help him.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60978 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 10:55:13 +00:00
Chris Lattner
7f50863e52 add a new pop_back_val method which returns the value popped. This is
heretical from a STL standpoint, but is oh-so-useful for things that 
can't throw exceptions when copied, like, well, everything in LLVM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60587 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 07:11:05 +00:00
Dan Gohman
254a886057 Implement a SmallVector insert method that can insert multiple
copies of a value, and add several additional utilities to make
SmallVector better conform to the Container concept.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57616 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-16 00:15:24 +00:00
Rafael Espindola
73c3a94df9 Add bound checks in SmallVector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56432 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-22 10:06:26 +00:00
Dan Gohman
1501cdbf63 Fix SmallVector's size calculation so that a size of 0 is
handled correctly, and change a few SmallVector uses to use
size 0 to more clearly reflect their intent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55181 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 16:07:55 +00:00
Owen Anderson
0c5a560b03 Add a value_type typedef to SmallVector, to make it more compatible with STL adapters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54819 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-15 18:45:51 +00:00
Dan Gohman
d24c62c67e Remove unnecessary static_casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53181 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 18:08:20 +00:00
Seo Sanghyeon
ff4d609ec5 Compilation fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52950 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-01 05:27:28 +00:00
Dan Gohman
f4d7708972 Make SmallVector's grow use memcpy in common cases
instead of std::uninitialized_copy, which uses memmove.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52928 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-30 21:45:13 +00:00
Dan Gohman
7c6618926a Use plain operator new instead of new char[].
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52927 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-30 21:33:02 +00:00
Dan Gohman
11bf2ace55 Add an operator< for SmallVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51791 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 22:37:47 +00:00
Anton Korobeynikov
43d1fd449f For PR1338: rename include/llvm/ADT/ilist and friends to end with ".h"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51687 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 17:41:17 +00:00
Bill Wendling
13d57320bd Remove warnings about unused parameters and shadowed variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51266 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 20:15:12 +00:00
Evan Cheng
34cd4a484e Fix more -Wshorten-64-to-32 warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 18:30:58 +00:00
Chris Lattner
b606dba13b Remove the SmallVector ctor that converts from a SmallVectorImpl. This
conversion open the door for many nasty implicit conversion issues, and
can be easily solved by initializing with (V.begin(), V.end()) when 
needed.

This patch includes many small cleanups for sdisel also.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50340 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 06:44:42 +00:00
Chris Lattner
e49e52d856 restore the copy ctor in SmallVector. This fixes serious
errors I introduced in my last patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50338 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 06:32:08 +00:00
Chris Lattner
5da0b73aa1 generalize SmallVector copy ctor, there is no requirement for
the initialization vector to have the same fixed size, just the
same element type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50334 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 06:01:06 +00:00
David Greene
a022e3fc2f Iterators folloring a SmallVector erased element are invalidated so
don't access cached iterators from after the erased element.

Re-apply 49056 with SmallVector support.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49106 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-02 18:24:46 +00:00
Chris Lattner
8874628e30 add operator==/!= to smallvector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45872 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-11 18:42:02 +00:00
Chris Lattner
7ed47a1335 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.  Boy are my fingers tired. ;-)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45411 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 19:59:42 +00:00
Chris Lattner
8568122b41 add reverse iterators to smallvector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41198 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-20 21:22:48 +00:00
Reid Spencer
276222a5ae Change casts from old style to new style. This helps document the details
better, gives the compiler a chance to validate the cast and reduces warnings
if the user turns on -Wold-style-cast option.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41033 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-12 08:12:35 +00:00
Chris Lattner
4f155b4c85 memcpy with zero length is hugely expensive, so avoid it. This speeds up coallescing from 1.17s to 0.88s on siod.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40984 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 07:02:50 +00:00
Chris Lattner
02cee38647 small speedup in the case where a smallvector is default ctor'd from
an empty vector.  This speeds up llc slightly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40983 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 06:54:38 +00:00
Dan Gohman
59310c3dc0 Add an explicit keyword. Thanks Chris!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37819 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-29 22:16:25 +00:00
Dan Gohman
8b42bcdd1a Add a default parameter to a SmallVector constructor to allow it to
be called with just an initial length value, just like in std::vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37779 91177308-0d34-0410-b5e6-96231b3b80d8
2007-06-28 20:27:24 +00:00
Chris Lattner
26b146ccf1 silence some "comparison between signed and unsigned integer expressions"
warnings


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37177 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-17 20:01:40 +00:00
Dan Gohman
df799afbec Fix some sporadic segfaults that are triggered when SmallVector's heap
storage lands near the end of the available address space. In the expression
Begin+N > Capacity, the Begin+N was overflowing. Fix this by replacing it
by with an expression that doesn't involve computation of an address
beyond the end of allocated memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37171 91177308-0d34-0410-b5e6-96231b3b80d8
2007-05-17 18:29:01 +00:00
Jeff Cohen
3f520a7111 Fix some VC++ warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36259 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-19 02:04:09 +00:00
Jeff Cohen
72adee00f6 The hack won't work on VS 2005, and it might not be needed anyway.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34930 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 17:22:33 +00:00
Jeff Cohen
f15bd1b9c6 Elminate tabs and improve comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34921 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 00:46:22 +00:00
Jeff Cohen
ca5183d445 Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34917 91177308-0d34-0410-b5e6-96231b3b80d8
2007-03-05 00:00:42 +00:00
Chris Lattner
8c06509f95 fix a critical bug in smallvector, where it would destroy elements that are
not in its range (!).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34230 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-13 07:25:36 +00:00
Chris Lattner
af3e4d4bee add missing ctor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33714 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-31 20:08:34 +00:00
Chris Lattner
09b6ac92d8 add a new form of insert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31290 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-30 05:07:51 +00:00
Chris Lattner
dd94c8d6b2 Add SmallString a (currently) minimal class that adapts SmallVector to be
more string-like.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31289 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-30 03:39:20 +00:00
Andrew Lenharth
f2bdcb3187 Fix build error in gcc 3.4 and make more this general
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30839 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-09 19:05:44 +00:00
Chris Lattner
53b06db6c7 Fix PR897
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30820 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-08 22:28:34 +00:00
Chris Lattner
0750bec272 add a simple reserve method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30011 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-01 06:08:16 +00:00
Chris Lattner
181c359c9d Add 2nd form of resize
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29945 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-28 21:52:08 +00:00