summaryrefslogtreecommitdiffstats
path: root/libcxx/include/list
Commit message (Collapse)AuthorAgeFilesLines
* [libc++] Rework compressed pair constructors.Eric Fiselier2019-12-161-1/+1
| | | | | | | | | | | | This patch de-duplicates most compressed pair constructors to use the same code in C++11 and C++03. Part of doing that is deleting the "__second_tag()" and replacing it with a "__value_init_tag()" which has the same effect, but allows for the removal of the special "one-arg" first element constructor. This patch is intended to have no semantic change.
* Rename __is_foo_iterator traits to reflect their Cpp17 nature.Eric Fiselier2019-11-181-8/+8
| | | | | | | | | With the upcoming introduction of iterator concepts in ranges, the meaning of "__is_contiguous_iterator" changes drastically. Currently we intend it to mean "does it have this iterator category", but it could now also mean "does it meet the requirements of this concept", and these can be different.
* [NFC] Strip trailing whitespace from libc++Louis Dionne2019-10-231-1/+1
|
* Make forward_list::remove/remove_if/unique all return void before C++20; ↵Marshall Clow2019-07-081-6/+7
| | | | | | undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365290
* Make list::remove/remove_if/unique all return void before C++20; undoes that ↵Marshall Clow2019-07-061-14/+19
| | | | | | bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365261
* Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed ↵Marshall Clow2019-07-011-18/+16
| | | | | | as https://reviews.llvm.org/D58332, and then updated because I rewrote a couple of those routines to eliminate some UB. Thanks to Zoe for tghe patch. llvm-svn: 364840
* Fix list/forward_list implementations of remove_if and unique to deal with ↵Marshall Clow2019-04-161-3/+8
| | | | | | predicates that are part of the sequence passed in. We already do this for remove. llvm-svn: 358534
* Remove exception throwing debug mode handler support.Eric Fiselier2019-03-181-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The reason libc++ implemented a throwing debug mode handler was for ease of testing. Specifically, I thought that if a debug violation aborted, we could only test one violation per file. This made it impossible to test debug mode. Which throwing behavior we could test more! However, the throwing approach didn't work either, since there are debug violations underneath noexcept functions. This lead to the introduction of `_NOEXCEPT_DEBUG`, which was only noexcept when debug mode was off. Having thought more and having grown wiser, `_NOEXCEPT_DEBUG` was a horrible decision. It was viral, it didn't cover all the cases it needed to, and it was observable to the user -- at worst changing the behavior of their program. This patch removes the throwing debug handler, and rewrites the debug tests using 'fork-ing' style death tests. Reviewers: mclow.lists, ldionne, thomasanderson Reviewed By: ldionne Subscribers: christof, arphaman, libcxx-commits, #libc Differential Revision: https://reviews.llvm.org/D59166 llvm-svn: 356417
* [libc++] Fix use-after-free when building with _LIBCPP_DEBUG=1Thomas Anderson2019-03-061-41/+47
| | | | | | | | | | | | | | | | | | | | | | | The issue is the following code: __cn1->__add(*__ip); (*__ip)->__c_ = __cn1; `__ip` points into the array of iterators for container `__cn2`. This code adds the iterator to the array of iterators for `__cn1`, and updates the iterator to point to the new container. This code works fine, except when `__cn1` and `__cn2` are the same container. `__cn1->__add()` might need to grow the array of iterators, and when it does, `__ip` becomes invalid, so the second line becomes a use-after-free error. Simply swapping the order of the above two lines is not sufficient, because of the memmove() below. The easiest and most performant solution is just to skip touching any iterators if the containers are the same. Differential Revision: https://reviews.llvm.org/D58926 llvm-svn: 355550
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Implement P1209 - Adopt Consistent Container Erasure from Library ↵Marshall Clow2018-12-141-0/+17
| | | | | | Fundamentals 2 for C++20. Reviewed as https://reviews.llvm.org/D55532 llvm-svn: 349178
* [NFC] Fix incorrect comment in std::listLouis Dionne2018-11-031-1/+1
| | | | llvm-svn: 346072
* Implement the infrastructure for feature-test macros. Very few actual ↵Marshall Clow2018-09-121-0/+1
| | | | | | feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 llvm-svn: 342073
* Implement LWG #3017. list splice functions should use addressofMarshall Clow2018-09-121-1/+1
| | | | llvm-svn: 342057
* Fix PR37694 - std::vector doesn't correctly move construct allocators.Eric Fiselier2018-06-051-11/+24
| | | | | | | | | | | | | | | | | | | C++2a[container.requirements.general]p8 states that when move constructing a container, the allocator is move constructed. Vector previously copy constructed these allocators. This patch fixes that bug. Additionally it cleans up some unnecessary allocator conversions when copy constructing containers. Libc++ uses __internal_allocator_traits::select_on_copy_construction to select the correct allocator during copy construction, but it unnecessarily converted the resulting allocator to the user specified allocator type and back. After this patch list and forward_list no longer do that. Technically we're supposed to be using allocator_traits<allocator_type>::select_on_copy_construction, but that should seemingly be addressed as a separate patch, if at all. llvm-svn: 334053
* Deduction guides for listMarshall Clow2018-05-201-2/+24
| | | | llvm-svn: 332818
* Fix PR35564 - std::list splice/erase incorrectly throw in debug mode.Eric Fiselier2018-01-251-4/+4
| | | | | | | | | | | | There was a bug in the implementation of splice where the container sizes were updated before decrementing one of the iterators. Afterwards, the result of decrementing the iterator was flagged as UB by the debug implementation because the container was reported to be empty. This patch fixes that bug by delaying the updating of the container sizes until after the iterators have been correctly constructed. llvm-svn: 323390
* First part of P0600 - '[[nodiscard] in the standard library'. Mark the ↵Marshall Clow2017-11-151-1/+1
| | | | | | 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only llvm-svn: 318269
* Fix misguided error message in debug mode. No functional change. Fixes PR#34966Marshall Clow2017-10-231-1/+1
| | | | llvm-svn: 316343
* Refactor std::list node allocation logic.Eric Fiselier2017-10-171-33/+23
| | | | | | | | | | | | The logic to allocate a node within std::list was repeated in a bunch of places. This is unneeded. This patch refactors the shared logic into a single function to reduce duplication. This patch is part of a set to clean up node construction in general, but refactoring construction requires some more work to make it work cleanly in C++03 llvm-svn: 316021
* [libc++] Fix PR34898 - vector iterator constructors and assign method ↵Eric Fiselier2017-10-171-2/+11
| | | | | | | | | | | | | | | | | | | | | | | perform push_back instead of emplace_back. Summary: The constructors `vector(Iter, Iter, Alloc = Alloc{})` and `assign(Iter, Iter)` don't correctly perform EmplaceConstruction from the result of dereferencing the iterator. This results in them performing an additional and unneeded copy. This patch addresses the issue by correctly using `emplace_back` in C++11 and newer. There are also some bugs in our `insert` implementation, but those will be handled separately. @mclow.lists We should probably merge this into 5.1, agreed? Reviewers: mclow.lists, dlj, EricWF Reviewed By: mclow.lists, EricWF Subscribers: cfe-commits, mclow.lists Differential Revision: https://reviews.llvm.org/D38757 llvm-svn: 315994
* [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on WindowsEric Fiselier2017-05-311-2/+6
| | | | | | | | | | | | | | | | Summary: This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning. This patch changes libc++ to use `#pragma push_macro` to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header. Reviewers: mclow.lists, bcraig, compnerd, EricWF Reviewed By: EricWF Subscribers: cfe-commits, krytarowski Differential Revision: https://reviews.llvm.org/D33080 llvm-svn: 304357
* Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <list>Eric Fiselier2017-04-161-64/+44
| | | | llvm-svn: 300414
* Change the return type of emplace_[front|back] back to void when building ↵Marshall Clow2017-01-241-2/+26
| | | | | | with C++14 or before. Resolves PR31680. llvm-svn: 292990
* [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VISEric Fiselier2017-01-041-5/+5
| | | | | | | | | | | | | The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both _LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to __attribute__((__type_visibility__)) with Clang. The only remaining difference is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas _LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on templates). This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS. llvm-svn: 291035
* Fix debug mode for vector/list and cleanup testsEric Fiselier2016-12-281-21/+23
| | | | llvm-svn: 290657
* Fix unused parameters and variablesEric Fiselier2016-12-231-4/+4
| | | | llvm-svn: 290459
* Fix PR31378 - std::list::remove should not require a default constructible ↵Eric Fiselier2016-12-141-1/+1
| | | | | | | | | | | | allocator. In list::remove we collect the nodes we're removing in a seperate list instance. However we construct this list using the default constructor which default constructs the allocator. However allocators are not required to be default constructible. This patch fixes the construction of the second list. llvm-svn: 289735
* [libcxx] Fix max_size() across all containersEric Fiselier2016-11-231-1/+9
| | | | | | | | | | | | Summary: The `max_size()` method of containers should respect both the allocator's reported `max_size` and the range of the `difference_type`. This patch makes all containers choose the smallest of those two values. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26885 llvm-svn: 287729
* Fix breakage introduced by adding -Wshadow.Eric Fiselier2016-10-231-27/+27
| | | | llvm-svn: 284946
* Implement P0084r2. Changing emplace return types.Eric Fiselier2016-07-211-8/+8
| | | | llvm-svn: 276230
* Cleanup: move visibility/linkage attributes to the first declaration.Evgeniy Stepanov2016-04-221-16/+31
| | | | | | http://reviews.llvm.org/D15404 llvm-svn: 267093
* Remove unsafe "__as_link()" cast member function.Eric Fiselier2016-01-041-27/+53
| | | | | | | | | | | "__as_link()" can only be used safely on "__list_node" objects. This patch moves the "__as_link()" member function from "__list_node_base" to "__list_node" so it cannot be used incorrectly. Unsafe downcasts now use a non-member function so we don't defer the type-punned pointer. llvm-svn: 256727
* [libcxx] Fix for ALL undefined behavior in <list>.Eric Fiselier2015-12-301-129/+163
| | | | | | | | | | | | | | Summary: This patch fixes std::list for builtin pointer types in the current ABI version and fixes std::list for all fancy pointer types in the next ABI version. The patch was designed to minimize the amount of code needed to support both ABI configurations. Currently only ~5 lines of code differ. Reviewers: danalbert, jroelofs, mclow.lists Subscribers: dexonsmith, awi, cfe-commits Differential Revision: http://reviews.llvm.org/D12299 llvm-svn: 256652
* Recommit rL245802: Cleanup fancy pointer rebinding in list using ↵Eric Fiselier2015-08-231-39/+10
| | | | | | | | | | | | __rebind_pointer. Currently we need an #ifdef branch every time we use pointer traits to rebind a pointer because it is done differently in C++11 and C++03. This patch introduces the __rebind_pointer utility to clean this up. Also add a test that list and it's iterators can be instantiated with incomplete element types. llvm-svn: 245806
* Revert r245802. It violates the incomplete type requirements. Eric Fiselier2015-08-231-8/+39
| | | | llvm-svn: 245805
* Cleanup fancy pointer rebinding in list using __rebind_pointer.Eric Fiselier2015-08-231-39/+8
| | | | | | | | Currently we need an #ifdef branch every time we use pointer traits to rebind a pointer because it is done differently in C++11 and C++03. This patch introduces the __rebind_pointer utility to clean this up. llvm-svn: 245802
* Implement the first part of N4258: 'Cleaning up noexcept in the Library'. ↵Marshall Clow2015-07-131-25/+18
| | | | | | This patch deals with swapping containers, and implements a more strict noexcept specification (a conforming extension) than the standard mandates. llvm-svn: 242056
* In many places, there was an #ifdef/#else block that selected one of two ↵Marshall Clow2015-04-071-14/+2
| | | | | | implmentations of rebind_alloc based on whether or not we had template aliases. Create a helper struct to encapsulate that bit of logic, and replace all the ifdefs with uses of that struct. No functionality change intented. llvm-svn: 234296
* Fix use after free and calls to operator comma in debug modeEric Fiselier2015-03-191-1/+1
| | | | llvm-svn: 232703
* Move the default template arguments into the forward declarations for the ↵Marshall Clow2015-02-181-2/+2
| | | | | | containers: deque, forwardlist and list. References PR#22605. llvm-svn: 229705
* 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
* While reading LWG#526, Ion Gaztañaga noticed that libc++ didn't correctly ↵Marshall Clow2014-08-081-12/+14
| | | | | | handle list::remove(const value_type &x), if x was an element of the list. Added a test for this, and a fix. Thanks to Ion for the report. llvm-svn: 215210
* dit pointed out on IRC that '__i = _VSTD::next(__i)' was a very long-winded ↵Marshall Clow2014-08-051-29/+49
| | | | | | way of writing '++__i'. Since I hate being thought of as long-winded (this checkin comment notwithstanding), I fixed it. No functionality change. llvm-svn: 214834
* Fix PR#202520 - predicate called too many times in list::remove_if. Add ↵Marshall Clow2014-08-041-0/+4
| | | | | | tests for list, forward_list, and the std::remove_if algorithm llvm-svn: 214736
* Update synopsis for list/forward_list/deque to match the allocator style of ↵Marshall Clow2013-09-091-1/+1
| | | | | | existing comment. No code change llvm-svn: 190320
* LWG Issue 2210 (Part #2 & #3): list and forward_listMarshall Clow2013-09-081-2/+22
| | | | llvm-svn: 190279
* Rename _LIBCPP_DEBUG2 to _LIBCPP_DEBUG.Howard Hinnant2013-08-231-1/+1
| | | | llvm-svn: 189140
* 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
* Implement NULL iterators for <list> re: N3644Marshall Clow2013-08-051-2/+2
| | | | llvm-svn: 187740
OpenPOWER on IntegriCloud