summaryrefslogtreecommitdiffstats
path: root/libcxx/include
Commit message (Collapse)AuthorAgeFilesLines
* Instead of asking glibc to provide correct C++ signatures for <string.h>Richard Smith2016-02-111-9/+5
| | | | | | | | functions, ask it whether it did provide them after the fact. Some versions of glibc fail to compile if you make this request and don't also claim to be at least GCC 4.3. llvm-svn: 260622
* Fix LWG issue 2469 - Use piecewise construction in unordered_map::operator[].Eric Fiselier2016-02-111-30/+21
| | | | | | | | | | | | | unordered_map's allocator may only be used to construct objects of 'value_type', or in this case 'pair<const Key, Value>'. In order to respect this requirement in operator[], which requires default constructing the 'mapped_type', we have to use pair's piecewise constructor with '(tuple<Kep>, tuple<>)'. Unfortunately we still need to provide a fallback implementation for C++03 since we don't have <tuple>. Even worse this fallback is the last remaining user of '__hash_map_node_destructor' and '__construct_node_with_key'. llvm-svn: 260601
* Work around regression in glibc 2.22: request that glibc provides the correctRichard Smith2016-02-111-0/+4
| | | | | | | prototypes for <string.h> functions that are converted into overload sets in C++. This matches the existing workaround in <wchar.h>. llvm-svn: 260570
* Revert r260514 because it has a bogus commit message.Eric Fiselier2016-02-111-21/+30
| | | | llvm-svn: 260556
* Properly down-cast a sentinal node pointer through void*Eric Fiselier2016-02-111-1/+2
| | | | llvm-svn: 260526
* Teach __hash_table how to handle unordered_map's __hash_value_type.Eric Fiselier2016-02-111-30/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is fairly large and contains a number of changes. The main change is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately this change is a rampant layering violation, but it's required to make unordered_map conforming without re-writing all of __hash_table. After this change 'unordered_map' can delegate to '__hash_table' in almost all cases. The major changes found in this patch are: * Teach __hash_table to differentiate between the true container value type and the node value type by introducing the "__container_value_type" and "__node_value_type" typedefs. In the case of unordered_map '__container_value_type' is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'. * Switch almost all overloads in '__hash_table' previously taking 'value_type' (AKA '__node_value_type) to take '__container_value_type' instead. Previously 'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because of the function signature. * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to '__key_value_types'. These functions allow '__hash_table' to unwrap '__node_value_type' objects into '__container_value_type' and its sub-parts. * Pass '__hash_value_type::__value_' to 'a.construct(p, ...)' instead of '__hash_value_type' itself. The C++14 standard requires that 'a.construct()' and 'a.destroy()' are only ever instantiated for the containers value type. * Remove '__hash_value_type's constructors and destructors. We should never construct an instance of this type. (TODO this is UB but we already do it in plenty of places). * Add a generic "try-emplace" function to '__hash_table' called '__emplace_unique_key_args(Key const&, Args...)'. The following changes were done as cleanup: * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'. * Cleanup C++11 only overloads that assume an incomplete C++11 implementation. For example this patch removes the __construct_node overloads that do manual pack expansion. * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code resulting from the change. This includes almost all 'unordered_map::__construct_node' overloads. The following changes are planed for future revisions: * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use '__emplace_unique_key_args'. * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'. * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible. This prevent unneeded allocations when inserting duplicate entries. The additional follow up work needed after this patch: * Respect the lifetime rules for '__hash_value_type' by actually constructing it. * Make '__insert_multi' act similar to '__insert_unique' for objects of type 'T&' and 'T const &&' with 'T = __container_value_type'. llvm-svn: 260514
* Teach __hash_table how to handle unordered_map's __hash_value_type.Eric Fiselier2016-02-114-357/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is fairly large and contains a number of changes. The main change is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately this change is a rampant layering violation, but it's required to make unordered_map conforming without re-writing all of __hash_table. After this change 'unordered_map' can delegate to '__hash_table' in almost all cases. The major changes found in this patch are: * Teach __hash_table to differentiate between the true container value type and the node value type by introducing the "__container_value_type" and "__node_value_type" typedefs. In the case of unordered_map '__container_value_type' is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'. * Switch almost all overloads in '__hash_table' previously taking 'value_type' (AKA '__node_value_type) to take '__container_value_type' instead. Previously 'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because of the function signature. * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to '__key_value_types'. These functions allow '__hash_table' to unwrap '__node_value_type' objects into '__container_value_type' and its sub-parts. * Pass '__hash_value_type::__value_' to 'a.construct(p, ...)' instead of '__hash_value_type' itself. The C++14 standard requires that 'a.construct()' and 'a.destroy()' are only ever instantiated for the containers value type. * Remove '__hash_value_type's constructors and destructors. We should never construct an instance of this type. (TODO this is UB but we already do it in plenty of places). * Add a generic "try-emplace" function to '__hash_table' called '__emplace_unique_key_args(Key const&, Args...)'. The following changes were done as cleanup: * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'. * Cleanup C++11 only overloads that assume an incomplete C++11 implementation. For example this patch removes the __construct_node overloads that do manual pack expansion. * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code resulting from the change. This includes almost all 'unordered_map::__construct_node' overloads. The following changes are planed for future revisions: * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use '__emplace_unique_key_args'. * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'. * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible. This prevent unneeded allocations when inserting duplicate entries. The additional follow up work needed after this patch: * Respect the lifetime rules for '__hash_value_type' by actually constructing it. * Make '__insert_multi' act similar to '__insert_unique' for objects of type 'T&' and 'T const &&' with 'T = __container_value_type'. llvm-svn: 260513
* Remove changes that snuck in within r260431Eric Fiselier2016-02-101-9/+0
| | | | llvm-svn: 260443
* Fix invalid casts in <functional>.Evgeniy Stepanov2016-02-102-29/+37
| | | | | | | | | | | | | static_cast of a pointer to object before the start of the object's lifetime has undefined behavior. This code triggers CFI warnings. This change replaces C-style casts with reinterpret_cast, which is fine per the standard, add applies an attribute to silence CFI (which barks on reinterpret_cast, too). llvm-svn: 260441
* Recommit r260012 - Cleanup node-type handling in the unordered containers.Eric Fiselier2016-02-104-72/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | This time I kept <ext/hash_map> working! This patch is the first in a series of patches that's meant to better support unordered_map. unordered_map has a special "value_type" that differs from pair<const Key, Value>. In order to meet the EmplaceConstructible and CopyInsertable requirements we need to teach __hash_table about this special value_type. This patch creates a "__hash_node_types" traits class that contains all of the typedefs needed by the unordered containers and it's iterators. These typedefs include ones for each node type and node pointer type, as well as special typedefs for "unordered_map"'s value type. As a result of this change all of the unordered containers now all support incomplete types. As a drive-by fix I changed the difference_type in __hash_table to always be ptrdiff_t. There is a corresponding change to size_type but it cannot take affect until an ABI break. This patch will be followed up shortly with fixes for various unordered_map bugs and problems. llvm-svn: 260431
* Limit catopen usage to unix-like OSesBen Craig2016-02-101-2/+4
| | | | | | | | | | | | Operating systems that are not unix-like are unlikely to have access to catopen. Instead of black-listing each one, we now filter out all non-unix operating systems first. We then exclude the unix-like operating systems that don't have catopen. _WIN32 counts as a unix-like operating system because of cygwin. http://reviews.llvm.org/D16639 llvm-svn: 260381
* Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr fromRichard Smith2016-02-105-37/+156
| | | | | | | | | | | | | | | | | <string.h> and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from <wchar.h> to provide a const-correct overload set even when the underlying C library does not. This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined) specifies that a given overload is a better match than an otherwise equally good function declaration without the overload. This is implemented in modern versions of Clang via __attribute__((enable_if)), and not elsewhere. We use this new macro to define overloads in the global namespace for these functions that displace the overloads provided by the C library, unless we believe the C library is already providing the correct signatures. llvm-svn: 260337
* Use the reserved spellings for attributesSaleem Abdulrasool2016-02-091-1/+1
| | | | | | Change the no_sanitize attribute to use the reserved spelling. llvm-svn: 260195
* Revert r260012 due to __gnu_cxx::hash_map breakageEric Fiselier2016-02-083-195/+71
| | | | llvm-svn: 260172
* Cleanup node-type handling in the unordered containersEric Fiselier2016-02-073-71/+195
| | | | | | | | | | | | | | | | | | | | | | | | | This patch is the first in a series of patches that's meant to better support unordered_map. unordered_map has a special "value_type" that differs from pair<const Key, Value>. In order to meet the EmplaceConstructible and CopyInsertable requirements we need to teach __hash_table about this special value_type. This patch creates a "__hash_node_types" traits class that contains all of the typedefs needed by the unordered containers and it's iterators. These typedefs include ones for each node type and node pointer type, as well as special typedefs for "unordered_map"'s value type. As a result of this change all of the unordered containers now all support incomplete types. As a drive-by fix I changed the difference_type in __hash_table to always be ptrdiff_t. There is a corresponding change to size_type but it cannot take affect until an ABI break. This patch will be followed up shortly with fixes for various unordered_map fixes. llvm-svn: 260012
* re.results.form: Format out-of-range subexpression references as nullDuncan P. N. Exon Smith2016-02-031-4/+4
| | | | | | | | | | Rather than crashing in match_results::format() when a reference to a marked subexpression is out of range, format the subexpression as empty (i.e., replace it with an empty string). Note that match_results::operator[]() has a range-check and returns a null match in this case, so this just re-uses that logic. llvm-svn: 259682
* Left a file out of r259014Marshall Clow2016-01-281-0/+114
| | | | llvm-svn: 259015
* Fix broken commit r258888. I missed adding two pointer conversionsEric Fiselier2016-01-271-2/+2
| | | | llvm-svn: 258893
* [libcxx] Fix undefined behavior in forward_listEric Fiselier2016-01-272-73/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is similar to the <list> fix but it has a few differences. This patch doesn't use a `__link_pointer` typedef because we don't need to change the linked list pointers because `forward_list` never stores a `__forward_begin_node` in the linked list itself. The issue with `forward_list` is that the iterators store pointers to `__forward_list_node` and not `__forward_begin_node`. This is incorrect because `before_begin()` and `cbefore_begin()` return iterators that point to a `__forward_begin_node`. This means we incorrectly downcast the `__forward_begin_node` pointer to a `__node_pointer`. This downcast itself is sometimes UB but it cannot be safely removed until ABI v2. The more common cause of UB is when we deference the downcast pointer. (for example `__ptr_->__next_`). This can be fixed without an ABI break by upcasting `__ptr_` before accessing it. The fix is as follows: 1. Introduce a `__iter_node_pointer` typedef that works similar to `__link_pointer` in the last patch. In ABI v2 it is always a typedef for `__begin_node_pointer`. 2. Change the `__before_begin()` method to return the correct pointer type (`__begin_node_pointer`), Previously it incorrectly downcasted the `__forward_begin_node` to a `__node_pointer` so it could be used to constructor the iterator types. 3. Change `__forward_list_iterator` and `__forward_list_const_iterator` in the following way: 1. Change `__node_pointer __ptr_;` member to have the `__iter_node_pointer` type instead. 2. Add additional private constructors that accept `__begin_node_pointer` in addition to `__node_pointer` and then correctly cast them to the stored `__iter_node_pointer` type. 3. Add `__get_begin()` and `__get_node_unchecked()` accessor methods that correctly cast `__ptr_` to the expected pointer type. `__get_begin()` is always safe to use and should be preferred. `__get_node_unchecked()` can only be used on a deferencible iterator. 4. Replace direct access to `__forward_list_iterator::__ptr_` with the safe accessor methods. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15836 llvm-svn: 258888
* Remove dead code missed in r258852.Eric Fiselier2016-01-261-6/+0
| | | | llvm-svn: 258855
* Fix PR26103 - Error calling is_convertible with incomplete type. Patch from ↵Eric Fiselier2016-01-261-2/+1
| | | | | | Michael Daniels. llvm-svn: 258852
* Implement LWG#2385; remove the allocator-aware std::function::assign call. ↵Marshall Clow2016-01-251-1/+4
| | | | | | It was useless, and didn't actually *do anything* with the allocator. Now it's gone. On the off chance that someone is mistakenly calling it, it's only gone in C++1z llvm-svn: 258697
* Revert "unordered_map: Reuse insert logic in emplace when possible, NFC"Duncan P. N. Exon Smith2016-01-231-27/+3
| | | | | | | | This reverts commit r258575. EricWF sent me an email (no link since it was off-list) requesting to review this pre-commit instead of post-commit. llvm-svn: 258625
* unordered_map: Reuse insert logic in emplace when possible, NFCDuncan P. N. Exon Smith2016-01-221-3/+27
| | | | | | | | | | | | | | | | An upcoming commit will add an optimization to insert() that avoids unnecessary mallocs when we can safely extract the key type. This commit shares code between emplace() and insert(): - if emplace() is given a single argument, and - value_type is constructible from that argument so that we have a single code path for the two. I also updated the debug version of emplace_hint() to defer to emplace(), like the non-debug version does. In both cases, there should be NFC here. llvm-svn: 258575
* unordered: Rename __construct_node_hash() to allow forwarding, NFCDuncan P. N. Exon Smith2016-01-221-8/+10
| | | | | | | | | | | | | | Rename the version of __construct_node() that takes a hash as an argument to __construct_node_hash(), and use perfect-forwarding when Rvalue references are available. The primary motivation is to allow other types through, since unordered_map's value_type is different from __hash_table's value_type -- a follow-up will take advantage of this -- but the rename is general "goodness". There should be no functionality change here (aside from enabling the follow-up). llvm-svn: 258511
* Add __uncvref type for use in later patchesEric Fiselier2016-01-221-0/+7
| | | | llvm-svn: 258491
* Implement LWG#2101 'Some transformation types can produce impossible types' ↵Marshall Clow2016-01-211-12/+51
| | | | | | Introduced a new (internal) type trait '__is_referenceable' with tests. Use that trait in add_lvalue_reference, add_rvalue_reference and add_pointer. llvm-svn: 258418
* Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed ↵Marshall Clow2016-01-191-0/+3
| | | | | | as http://reviews.llvm.org/D16262 llvm-svn: 258107
* Tame a -Wunknown-attributes warningJonathan Roelofs2016-01-131-1/+1
| | | | llvm-svn: 257707
* Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the ↵Marshall Clow2016-01-133-74/+82
| | | | | | strong exception safety guarantee'. This turned out to be a pervasive problem in <string>, which required a fair amount of rework. Add in an optimization for when iterators provide noexcept increment/comparison/assignment/dereference (which covers many of the iterators in libc++). Reviewed as http://reviews.llvm.org/D15862 llvm-svn: 257682
* Update version to 3.9Hans Wennborg2016-01-131-1/+1
| | | | llvm-svn: 257629
* [WebAssembly] Set std::numeric_limits's traps field for WebAssembly.Dan Gohman2016-01-131-1/+2
| | | | | | | WebAssembly's integer division instruction traps on division by zero; set the traps field of integral std::numeric_limits to true. llvm-svn: 257612
* Put the definition of _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK in the ↵Marshall Clow2016-01-121-5/+5
| | | | | | right place. llvm-svn: 257422
* Preemptively disable unsigned integer sanitization in 32 and 64 bit versions ↵Marshall Clow2016-01-112-2/+11
| | | | | | of __murmur2_or_cityhash. This lets people use the unsigned integer overflow checker in UBSAN w/o getting hits from libc++'s hash code (where the unsigned integer overflow is legal and deliberate)> Patch by @danielaustin. Reviewed as: http://reviews.llvm.org/D15973 llvm-svn: 257368
* Revert "Remove visibility attributes from out-of-class method definitions in ↵Evgeniy Stepanov2016-01-084-86/+86
| | | | | | iostreams." llvm-svn: 257193
* First half of LWG#2354: 'Unnecessary copying when inserting into maps with ↵Marshall Clow2016-01-052-0/+75
| | | | | | braced-init syntax' llvm-svn: 256859
* 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
* Use __rebind_pointer to avoid #ifdef blockEric Fiselier2015-12-306-202/+46
| | | | llvm-svn: 256654
* [libcxx] Fix for ALL undefined behavior in <list>.Eric Fiselier2015-12-302-129/+165
| | | | | | | | | | | | | | 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
* [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default ↵Eric Fiselier2015-12-232-3/+14
| | | | | | | | | | | | | | constructors. Summary: This patch implements the solution for LWG Issue #2367. See http://cplusplus.github.io/LWG/lwg-active.html#2367 Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13750 llvm-svn: 256325
* [libcxx] LWG2485: get() should be overloaded for const tuple&&. Patch from ↵Eric Fiselier2015-12-184-2/+104
| | | | | | | K-Ballo. Review: http://reviews.llvm.org/D14839 llvm-svn: 255941
* Make noexcept specifications on __hash_table definitions match their ↵Eric Fiselier2015-12-161-0/+2
| | | | | | declarations. llvm-svn: 255738
* Workaround nasty GCC bug that caused testsuite to hangEric Fiselier2015-12-161-1/+3
| | | | llvm-svn: 255734
* Remove unused _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS macroEric Fiselier2015-12-151-4/+0
| | | | llvm-svn: 255686
* [libcxx] Enable noexcept for GCC 4.6 and greaterEric Fiselier2015-12-151-19/+15
| | | | | | | | | | | | | | | | Summary: This patch allows GCC 4.6 and above to use `noexcept` as opposed to `throw()`. Is it an ABI safe change to suddenly switch on `noexcept`? I imagine it must be because it's disabled in w/ clang in C++03 but not C++11. Reviewers: danalbert, jroelofs, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15516 llvm-svn: 255683
* Mark declarations of externally instantiated functions as inline so GCC ↵Eric Fiselier2015-12-151-2/+2
| | | | | | doesn't complain. llvm-svn: 255599
* Fix various GCC mis-configurations for newer versions.Eric Fiselier2015-12-152-1/+9
| | | | | | | | | | | | This patch goes through and enables C++11 and C++14 features for newer GCC's. The main changes are: 1. Turn on variable templates. (Uses __cpp_variable_templates) 2. Assert atomic<Tp> is trivially copyable (Uses _GNUC_VER >= 501). 3. Turn on trailing return support for GCC. (Uses _GNUC_VER >= 404) 4. XFAIL void_t test for GCC 5.1 and 5.2. Fixed in GCC 6. llvm-svn: 255585
* Missed this on the previous (255517) commitMarshall Clow2015-12-141-0/+49
| | | | llvm-svn: 255518
* Fix a corner case that involved calling rethrow_if_nested with a type that ↵Marshall Clow2015-12-142-52/+1
| | | | | | had a deleted operator&. Added a test to catch this as well. Thanks to Ville for the heads-up. llvm-svn: 255517
* Remove redundant _LIBCPP_ALWAYS_INLINE attribute from __convert_to_integral ↵Eric Fiselier2015-12-101-9/+9
| | | | | | overloads llvm-svn: 255185
OpenPOWER on IntegriCloud