summaryrefslogtreecommitdiffstats
path: root/libcxx/include/vector
Commit message (Collapse)AuthorAgeFilesLines
...
* [libcxx] Optimize vectors uninitialized construction of trivial types from ↵Eric Fiselier2015-03-311-23/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | an iterator range. Summary: In certain cases vector can use memcpy to construct a range of elements at the back of the vector. We currently don't do this resulting in terrible code gen in non-optimized mode and a very large slowdown compared to libstdc++. This patch adds a `__construct_forward_range(Allocator, Iter, Iter, _Ptr&)` and `__construct_forward_range(Allocator, Tp*, Tp*, Tp*&)` functions to `allocator_traits` which act similarly to the existing `__construct_forward(...)` functions. This patch also changes vectors `__construct_at_end(Iter, Iter)` to be `__construct_at_end(Iter, Iter, SizeType)` where SizeType is the size of the range. `__construct_at_end(Iter, Iter, SizeType)` now calls `allocator_traits<Tp>::__construct_forward_range(...)`. This patch is based off the design of `__swap_out_circular_buffer(...)` which uses `allocator_traits<Tp>::__construct_forward(...)`. On my machine this code performs 4x better than the current implementation when tested against `std::vector<int>`. Reviewers: howard.hinnant, titus, kcc, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8109 llvm-svn: 233711
* [libcxx] Fix __RAII_IncreaseAnnotator for increases >= 1Eric Fiselier2015-03-101-3/+3
| | | | | | | | | | | | | | Summary: Fix suggested by @mclow.lists on D8109. Store the size of the un-poisoned vector upon construction instead of calculating it later. Reviewers: titus, mclow.lists, kcc, EricWF Reviewed By: EricWF Subscribers: mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D8172 llvm-svn: 231729
* [libcxx] Fix vector annotator size increase in `vector::insert(pos, count, ↵Eric Fiselier2014-11-141-1/+1
| | | | | | | | | | | | | | | | | | value)` Summary: The size of the vector is being increased by `__n` during the call to `__move_range` and not by 1. This fixes a test failure in `containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp` when using ASAN. Reviewers: danalbert, kcc, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6264 llvm-svn: 222014
* Make the ASAN RAII object a nop when building w/o ASANMarshall Clow2014-09-031-0/+8
| | | | llvm-svn: 217082
* [asan] Make vector asan annotations exception-friendlyKostya Serebryany2014-09-021-31/+43
| | | | | | | | | Fix vector asan annotations with RAII. Add a test. Also, remove one dead function. Review: http://reviews.llvm.org/D4170 llvm-svn: 216995
* NFC. Move definition of _LIBCPP_ASSERT into __debug header and remove ↵Eric Fiselier2014-08-101-5/+1
| | | | | | | | | | | | | | | | | | external include guards. Things done in this patch: 1. Make __debug include __config since it uses macros from it. 2. The current method of defining _LIBCPP_ASSERT is prone to redefinitions. Move the null _LIBCPP_ASSERT definition into the __debug header to prevent this. 3. Remove external <__debug> include gaurds. <__debug> guards almost all of its contents internally. There is no reason to be doing it externally. This patch should not change any functionality. llvm-svn: 215332
* Fix PR#20471. Add a cast in __align_it to ensure that the bit twiddling is ↵Marshall Clow2014-07-281-1/+1
| | | | | | done at the correct size. A better solution, IMHO, would be to declare vector<bool>::__bits_per_word as 'size_type', rather than 'unsigned', but that's a possible ABI change. llvm-svn: 214088
* make the same change as in 213546 for vector<bool>Marshall Clow2014-07-211-1/+1
| | | | llvm-svn: 213547
* In response to bug #20362, change the order of operations in vector move ↵Marshall Clow2014-07-211-1/+1
| | | | | | assignment so that if the allocator move assignment throws, we aren't left with two objects pointing at the same memory. This is not a complete fix; I am unconvinced that a complete fix is possible. With this change in place, we will leak the old contents of the vector. LWG issue #2106, when adopted, will make this problem illegal. Thanks to Thomas Koeppe for the report and analysis. llvm-svn: 213546
* Add Address Sanitizer support to std::vectorMarshall Clow2014-05-081-0/+55
| | | | llvm-svn: 208319
* G M: Changes all references to "x inline" to "inline x" where x = ↵Howard Hinnant2013-10-041-40/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | _libcpp_always_inline or _libcpp_inline_visibility macros. The patch touches these files: locale array deque new string utility vector __bit_reference __split_buffer locale_win32.h There is no intended functionality change and it is expected that reversing the position of the inline keyword with regard to the other keywords does not change the meaning of anything, least not for apple/Linux etc. It is intended to make libcxx more consistent with itself and to prevent the 1000 or so "inline.cpp(3) : warning C4141: 'inline' : used more than once" warnings that MS's cl.exe compiler emits without this patch, i.e. if inline is not the first keyword before a function name etc. Prefer "inline [other inline related keyword]" over "[other related keyword] inline". After this patch, libcxx should be consistent to this pattern. llvm-svn: 191987
* Peter Collingbourne: If a pointer is passed as the third argument of the ↵Howard Hinnant2013-09-211-8/+12
| | | | | | | | | | | | (iterator, iterator, allocator) constructor with the intention of it being implicitly converted to the allocator type, it is possible for overload resolution to favour the (iterator, iterator, enable_if) constructor. Eliminate this possibility by moving the enable_if to one of the existing arguments and removing the third argument. llvm-svn: 191145
* LWG Issue 2210 (Part #7): vector and vector<bool>Marshall Clow2013-09-141-1/+40
| | | | llvm-svn: 190736
* Rename _LIBCPP_DEBUG2 to _LIBCPP_DEBUG.Howard Hinnant2013-08-231-1/+1
| | | | llvm-svn: 189140
* Remove _LIBCPP_DEBUG. This was my first attempt at debug mode for libc++, ↵Howard Hinnant2013-08-231-34/+0
| | | | | | and is now obsoleted by _LIBCPP_DEBUG2 (which isn't finished). llvm-svn: 189135
* Xing Xue: port to IBM XLC++/AIX.Howard Hinnant2013-08-141-2/+2
| | | | llvm-svn: 188396
* Implement LWG Issue #2187 (emplace_back and emplace for vector<bool>)Marshall Clow2013-08-131-0/+14
| | | | llvm-svn: 188333
* Nico Rieck: this patch series fixes visibility issues on Windows as ↵Howard Hinnant2013-08-121-5/+5
| | | | | | explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>. llvm-svn: 188192
* Ok, 3 major changes for debug mode in one commit:Howard Hinnant2013-08-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. I had been detecting and trapping iterator == and \!= among iterators in different containers as an error. But the trapping itself is actually an error. Consider: #include <iostream> #include <vector> #include <algorithm> template <class C> void display(const C& c) { std::cout << "{"; bool first = true; for (const auto& x : c) { if (\!first) std::cout << ", "; first = false; std::cout << x; } std::cout << "}\n"; } int main() { typedef std::vector<int> V; V v1 = {1, 3, 5}; V v2 = {2, 4, 6}; display(v1); display(v2); V::iterator i = std::find(v1.begin(), v1.end(), 1); V::iterator j = std::find(v2.begin(), v2.end(), 2); if (*i == *j) i = j; // perfectly legal // ... if (i \!= j) // the only way to check v2.push_back(*i); display(v1); display(v2); } It is legal to assign an iterator from one container to another of the same type. This is required to work. One might want to test whether or not such an assignment had been made. The way one performs such a check is using the iterator's ==, \!= operator. This is a logical and necessary function and does not constitute an error. 2. I had a header circular dependence bug when _LIBCPP_DEBUG2 is defined. This caused a problem in several of the libc++ tests. Fixed. 3. There is a serious problem when _LIBCPP_DEBUG2=1 at the moment in that std::basic_string is inoperable. std::basic_string uses __wrap_iterator to implement its iterators. __wrap_iterator has been rigged up in debug mode to support vector. But string hasn't been rigged up yet. This means that one gets false positives when using std::string in debug mode. I've upped std::string's priority in www/debug_mode.html. llvm-svn: 187636
* Nico Rieck: Currently _MSC_VER and _WIN32 are used to guard code which isHoward Hinnant2013-08-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | MSVC-specific, MSVCRT-specific, or Windows-specific. Because Clang can also define _MSC_VER, and MSVCRT is not necessarily the only C runtime, these macros should not be used interchangeably. This patch divides all Windows-related bits into the aforementioned categories. Two new macros are introduced: - _LIBCPP_MSVC: Defined when compiling with MSVC. Detected using _MSC_VER, excluding Clang. - _LIBCPP_MSVCRT: Defined when using the Microsoft CRT. This is the default when _WIN32 is defined. This leaves _WIN32 for code using the Windows API. This also corrects the spelling of _LIBCP_HAS_IS_BASE_OF to _LIBCPP_HAS_IS_BASE_OF. Nico, please prepare a patch for CREDITS.TXT, thanks. llvm-svn: 187593
* Implement full support for non-pointer pointers in custom allocators for vector.Howard Hinnant2013-06-271-52/+40
| | | | llvm-svn: 185093
* After years of telling people: 'If you ever find any of my code that ↵Howard Hinnant2013-04-181-1/+2
| | | | | | self-move-assigns, send me a bug report.' Somebody finally took me up on it. vector::erase(begin(), begin()) does a self-move-assign of every element in the vector, leaving all of those elements in an unspecified state. I checked the other containers for this same bug and did not find it. Added test case. llvm-svn: 179760
* Second try at r178075. The llvm breakage has been fixed by r178240.Howard Hinnant2013-03-281-16/+64
| | | | llvm-svn: 178253
* Revert r178075, "Tighten up the iterator requirements ...", it breaks LLVMDaniel Dunbar2013-03-271-64/+16
| | | | | | bootstrap with libc++. llvm-svn: 178116
* Tighten up the iterator requirements for the vector member templates. This ↵Howard Hinnant2013-03-261-16/+64
| | | | | | is especially important for the constructors so that is_constructible<vector<T>, I, I> gives the right answer when T can not be constructed from *I. Test case included for this latter point. llvm-svn: 178075
* Another vector debug mode test, and a static test on Allocator::value_type. ↵Howard Hinnant2013-03-261-0/+3
| | | | | | This partially addresses http://llvm.org/bugs/show_bug.cgi?id=15576. llvm-svn: 178064
* Added debug tests for indexing, pop_back and both forms of erase. Added an ↵Howard Hinnant2013-03-251-0/+2
| | | | | | improved error message for erasing a single element with end(). llvm-svn: 177929
* No functionality change at this time. I've split _LIBCPP_VISIBLE up into ↵Howard Hinnant2013-03-061-4/+4
| | | | | | two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute. llvm-svn: 176593
* Revert accidental check-in. These changes are probably good, but premature ↵Howard Hinnant2013-02-071-3/+3
| | | | | | at this point. llvm-svn: 174625
* Michael van der Westhuizen: The attached patch add support for building ↵Howard Hinnant2013-02-071-3/+3
| | | | | | | | | | | against libc++abi and libcxxrt to CMake builds of libc++. Usage (with the appropriate CC and CXX environment variables) is: $ cmake -DLIBCXX_CXX_ABI=libcxxabi '-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=/home/michael/libcxxabi/include' ../libcxx and: $ cmake -DLIBCXX_CXX_ABI=libcxxrt '-DLIBCXX_LIBCXXRT_INCLUDE_PATHS=/home/michael/libcxxrt/src' ../libcxx llvm-svn: 174623
* Fix exception safety bug in vector::push_backHoward Hinnant2013-01-111-2/+4
| | | | llvm-svn: 172250
* Provide a way to disable use of extern templates in libc++. This is ↵Howard Hinnant2012-11-061-1/+1
| | | | | | intended for the clients of libc++, not the libc++ build. The dylib should always contain the extern templates. To disable the client needs to put -D'_LIBCPP_EXTERN_TEMPLATE(...)=' on the command line. llvm-svn: 167486
* Don't neglect to "return *this".Argyrios Kyrtzidis2012-10-131-0/+1
| | | | llvm-svn: 165860
* Consistently label __bit_array as a struct, not a class.Howard Hinnant2012-08-171-1/+1
| | | | llvm-svn: 162108
* Change emplace for vector and deque to create the temporary (when necessary) ↵Howard Hinnant2012-07-081-1/+2
| | | | | | before any changes to the container are made. Nikolay Ivchenkov deserves the credit for pushing this problem and the solution for it. llvm-svn: 159918
* SFINAE __bit_iterator such that it will only get instantiated with a ↵Howard Hinnant2012-05-071-1/+1
| | | | | | container that has the nested type __storage_type. This prevents accidental instantiation such as in http://llvm.org/bugs/show_bug.cgi?id=12755. This fixes http://llvm.org/bugs/show_bug.cgi?id=12755. llvm-svn: 156308
* vector::emplace_back was mistakenly requiring move assignable. Fixed that ↵Howard Hinnant2012-02-261-6/+19
| | | | | | and did a little drive-by optimization at the same time. This fixes http://llvm.org/bugs/show_bug.cgi?id=12085. llvm-svn: 151492
* Implement a few optimizations for vector push_back and insert. Fixes r10828365.Howard Hinnant2012-02-151-22/+34
| | | | llvm-svn: 150542
* Quash a whole bunch of warningsHoward Hinnant2011-12-011-6/+6
| | | | llvm-svn: 145624
* Further macro protection by replacing _[A-Z] with _[A-Z]pHoward Hinnant2011-11-291-4/+4
| | | | llvm-svn: 145410
* Add protection from min/max macrosHoward Hinnant2011-11-291-0/+2
| | | | llvm-svn: 145407
* More windows port work by Ruben Van BoxemHoward Hinnant2011-10-221-0/+7
| | | | llvm-svn: 142732
* Windows support by Ruben Van Boxem.Howard Hinnant2011-10-171-0/+2
| | | | llvm-svn: 142235
* Chris Jefferson noted that vector iterator ownership can be transferred from ↵Howard Hinnant2011-09-191-2/+7
| | | | | | source to target under move construction and move assignment. This commit makes that happen for debug mode. llvm-svn: 140023
* The vector test suite now passes for no-debug, debug-lite and debug-regularHoward Hinnant2011-09-161-40/+40
| | | | llvm-svn: 139930
* Create multilevel debug modeHoward Hinnant2011-09-161-48/+43
| | | | llvm-svn: 139913
* Initial checkin for debug mode (version 2)Howard Hinnant2011-09-141-26/+183
| | | | llvm-svn: 139711
* Fix const correctness bug in __move_assign. Found and fixed by Ion Gaztañaga.Howard Hinnant2011-09-021-5/+5
| | | | llvm-svn: 139032
* Fixed PR10574: http://llvm.org/bugs/show_bug.cgi?id=10574Howard Hinnant2011-08-121-0/+24
| | | | llvm-svn: 137522
* Explicitly invoke the size_type specialization of max and min. ThisAlexis Hunt2011-07-291-2/+2
| | | | | | | | | avoids bugs where, when the allocator's size_type was smaller than int, the multiplication or division would cause integral promotions and, with two different integer types as arguments, deduction of the template arguments would fail. llvm-svn: 136540
OpenPOWER on IntegriCloud