summaryrefslogtreecommitdiffstats
path: root/libcxx/include/memory
Commit message (Collapse)AuthorAgeFilesLines
...
* [libc++] Remove various C++03 feature test macrosEric Fiselier2016-09-251-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Libc++ still uses per-feature configuration macros when configuring for C++11. However libc++ requires a feature-complete C++11 compiler so there is no reason to check individual features. This patch starts the process of removing the feature specific macros and replacing their usage with `_LIBCPP_CXX03_LANG`. This patch removes the __config macros: * _LIBCPP_HAS_NO_TRAILING_RETURN * _LIBCPP_HAS_NO_TEMPLATE_ALIASES * _LIBCPP_HAS_NO_ADVANCED_SFINAE * _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS * _LIBCPP_HAS_NO_STATIC_ASSERT As a drive I also changed our C++03 static_assert to use _Static_assert if available. I plan to commit this without review if nobody voices an objection. Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24895 llvm-svn: 282347
* [libcxx] Fix a data race in call_onceKuba Brecka2016-09-041-0/+12
| | | | | | | | call_once is using relaxed atomic load to perform double-checked locking, which contains a data race. The fast-path load has to be an acquire atomic load. Differential Revision: https://reviews.llvm.org/D24028 llvm-svn: 280621
* Followon to r279744. Find the other exception types and make __throw_XXX ↵Marshall Clow2016-08-251-4/+4
| | | | | | routines (and call them). Remove the generic __libcpp_throw routine, since no one uses it anymore. llvm-svn: 279763
* Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception ↵Marshall Clow2016-08-251-8/+11
| | | | | | type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855. llvm-svn: 279744
* Implement P0040r3: Extending memory management toolsEric Fiselier2016-07-241-0/+108
| | | | llvm-svn: 276544
* Always use the allocator to construct/destruct elements of a deque/vector. ↵Marshall Clow2016-07-111-0/+20
| | | | | | Fixes PR#28412. Thanks to Jonathan Wakely for the report. llvm-svn: 275105
* Implement P0163r0. Add shared_ptr::weak_type.Eric Fiselier2016-06-271-0/+4
| | | | | | | | | | This patch adds the weak_type typedef in shared_ptr. It is available in C++17 and newer. This patch also updates the _LIBCPP_STD_VER and TEST_STD_VER macros to have the value of 16, since 2016 is the current year. llvm-svn: 273839
* Fix PR27115 - enable_shared_from_this does not work as a virtual base class.Eric Fiselier2016-06-261-24/+23
| | | | | | | | | | | | | See https://llvm.org/bugs/show_bug.cgi?id=27115 The problem was that the conversion from 'const enable_shared_from_this<T>*' to 'const T*' didn't work if T inherited enable_shared_from_this as a virtual base class. The fix is to take the original pointer passed to shared_ptr's constructor in the __enable_weak_this method and perform an upcast to 'const T*' instead of performing a downcast from the enable_shared_from_this base. llvm-svn: 273835
* Enable building and using atomic shared_ptr for GCC.Eric Fiselier2016-06-181-4/+3
| | | | | | | | | | | | | | | | | Summary: Currently the implementation of [util.smartptr.shared.atomic] is provided only when using Clang, and not with GCC. This is a relic of not having a GCC implementation of <atomic>, even though <atomic> isn't actually used in the implementation. This patch enables support for atomic shared_ptr functions when using GCC. Note that this is not a header only change. Previously only Clang builds of libc++.so would provide the required symbols. There is no reason for this restriction. After this change both Clang and GCC builds should be binary compatible with each other WRT these symbols. Reviewers: mclow.lists, rmaprath, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21407 llvm-svn: 273076
* Fix leak in __enable_weak_this(). Thanks to Arthur O'Dwyer for finding it.Eric Fiselier2016-06-021-2/+4
| | | | llvm-svn: 271487
* Implement P0033R1 - Re-enabling shared_from_thisEric Fiselier2016-06-021-1/+11
| | | | | | | | | | | | Summary: See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0033r1.html Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19254 llvm-svn: 271449
* Change the control flow in atomic_compare_exchange_strong to avoid a ↵Marshall Clow2016-05-181-0/+3
| | | | | | | | potential deadlock. When you assign a shared_ptr, the deleter gets called and assigned. In this routine, the assignment happens inside a critical section, which could (potentially) lead to a deadlock, if the deleter did something wonky. Now we swap the old value with an (empty) temporary shared_ptr, and then let the temporary delete the old value when it goes out of scope (after the lock has been released). This should fix PR#27724. Thanks to Hans Boehm for the bug report and the suggested fix. llvm-svn: 269965
* Change allocator<T>::allocate to throw length_error, not bad_allocEric Fiselier2016-05-071-11/+6
| | | | llvm-svn: 268842
* Add is_swappable/is_nothrow_swappable traitsEric Fiselier2016-04-211-1/+4
| | | | llvm-svn: 267079
* Fix most GCC attribute ignored warningsEric Fiselier2016-04-211-6/+4
| | | | llvm-svn: 267074
* Fix for PR26812: possible overflow issue in std::allocator::allocateMarshall Clow2016-03-031-2/+18
| | | | llvm-svn: 262610
* Another chunk of N4089Marshall Clow2016-02-251-19/+2
| | | | llvm-svn: 261894
* Preemptively disable unsigned integer sanitization in 32 and 64 bit versions ↵Marshall Clow2016-01-111-2/+2
| | | | | | 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
* Add 3 more missing inline/visibility attributes.Evgeniy Stepanov2015-12-091-0/+2
| | | | | | | | | These are the cases when an out-of-class definition of a method is marked _LIBCPP_INLINE_VISIBILITY, but the in-class declaration is not. This will start failing when (or if) we switch to attribute((internal_linkage)). llvm-svn: 255166
* Implement P0074: Making owner_less more flexibleMarshall Clow2015-11-121-0/+28
| | | | llvm-svn: 252905
* Cleanup: move visibility/linkage attributes to the first declaration.Evgeniy Stepanov2015-11-071-36/+62
| | | | | | | | | | | | This change moves visibility attributes from out-of-class method definitions to in-class declaration. This is needed for a switch to attribute((internal_linkage)) (see http://reviews.llvm.org/D13925) which can only appear on the first declaration. This change does not touch istream/ostream/streambuf. They are handled separately in http://reviews.llvm.org/D14409. llvm-svn: 252385
* Add a test for LWG#2466: allocator_traits::max_size() default behavior is ↵Marshall Clow2015-10-251-1/+1
| | | | | | incorrect llvm-svn: 251252
* Fix LWG#2127: Move-construction with raw_storage_iterator.Marshall Clow2015-10-251-0/+4
| | | | llvm-svn: 251247
* [libcxx] Constrain unique_ptr::operator=(unique_ptr<Tp, Dp>) in C++03 modeEric Fiselier2015-08-281-2/+9
| | | | | | | | | | | | | | | | | Summary: This patch properly constrains the converting assignment operator in C++03. It also fixes a bug where std::forward was given the wrong type. The following two tests begin passing in C++03: * `unique_ptr.single.asgn/move_convert.pass.cpp` * `unique_ptr.single.asgn/move_convert13.fail.cpp` Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12173 llvm-svn: 246272
* Recommit rL245802: Cleanup fancy pointer rebinding in list using ↵Eric Fiselier2015-08-231-0/+9
| | | | | | | | | | | | __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-9/+0
| | | | llvm-svn: 245805
* Cleanup fancy pointer rebinding in list using __rebind_pointer.Eric Fiselier2015-08-231-0/+9
| | | | | | | | 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
* [libcxx] Allow use of <atomic> in C++03. Try 3.Eric Fiselier2015-08-191-3/+5
| | | | | | | | | | | | | | | | | | | | | | | Summary: After putting this question up on cfe-dev I have decided that it would be best to allow the use of `<atomic>` in C++03. Although static initialization is a concern the syntax required to get it is C++11 only. Meaning that C++11 constant static initialization cannot silently break in C++03, it will always cause a syntax error. Furthermore `ATOMIC_VAR_INIT` and `ATOMIC_FLAG_INIT` remain defined in C++03 even though they cannot be used because C++03 usages will cause better error messages. The main change in this patch is to replace `__has_feature(cxx_atomic)`, which only returns true when C++ >= 11, to `__has_extension(c_atomic)` which returns true whenever clang supports the required atomic builtins. This patch adds the following macros: * `_LIBCPP_HAS_C_ATOMIC_IMP` - Defined on clang versions which provide the C `_Atomic` keyword. * `_LIBCPP_HAS_GCC_ATOMIC_IMP` - Defined on GCC > 4.7. We must use the fallback atomic implementation. * `_LIBCPP_HAS_NO_ATOMIC_HEADER` - Defined when it is not safe to include `<atomic>`. `_LIBCPP_HAS_C_ATOMIC_IMP` and `_LIBCPP_HAS_GCC_ATOMIC_IMP` are mutually exclusive, only one should be defined. If neither is defined then `<atomic>` is not implemented and including `<atomic>` will issue an error. Reviewers: chandlerc, jroelofs, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11555 llvm-svn: 245463
* Broke C++03 compatibility in 245330. Fix that.Marshall Clow2015-08-181-1/+1
| | | | llvm-svn: 245336
* implement more of N4258 - Cleaning up noexcept in the standard library. ↵Marshall Clow2015-08-181-0/+9
| | | | | | Specifically add new noexcept stuff to vector and string's move-assignment operations llvm-svn: 245330
* Enable and fix warnings during the build.Eric Fiselier2015-07-181-3/+3
| | | | | | | | | | | | | | | | | Although CMake adds warning flags, they are ignored in the libc++ headers because the headers '#pragma system header' themselves. This patch disables the system header pragma when building libc++ and fixes the warnings that arose. The warnings fixed were: 1. <memory> - anonymous structs are a GNU extension 2. <functional> - anonymous structs are a GNU extension. 3. <__hash_table> - Embedded preprocessor directives have undefined behavior. 4. <string> - Definition is missing noexcept from declaration. 5. <__std_stream> - Unused variable. llvm-svn: 242623
* Make sure that __libcpp_compressed_pair_imp default-constructs its' members, ↵Marshall Clow2015-07-161-7/+7
| | | | | | rather than value-initializing them. Fixes PR#24137 llvm-svn: 242377
* Implement the first part of N4258: 'Cleaning up noexcept in the Library'. ↵Marshall Clow2015-07-131-0/+32
| | | | | | This patch deals with swapping containers, and implements a more strict noexcept specification (a conforming extension) than the standard mandates. llvm-svn: 242056
* [libcxx] Add atomic_support.h header to src that handles needed atomic ↵Eric Fiselier2015-07-071-1/+15
| | | | | | | | | | | | | | | | | | | | | operations. Summary: In some places in libc++ we need to use the `__atomic_*` builtins. This patch adds a header that provides access to those builtins in a uniform way from within the dylib source. If the compiler building the dylib does not support these builtins then a warning is issued. Only relaxed loads are needed within the headers. A singe function to do these relaxed loads has been added to `<memory>`. This patch applies the new atomic builtins to `__shared_count` and `call_once`. Reviewers: mclow.lists Subscribers: majnemer, jroelofs, cfe-commits Differential Revision: http://reviews.llvm.org/D10406 llvm-svn: 241532
* Noticed that std::allocator<const T> was missing the definition for ↵Marshall Clow2015-07-011-0/+1
| | | | | | is_always_equal. Fixed this, and added a test for it. llvm-svn: 241190
* Fix illegal chars that snuck into <memory>Marshall Clow2015-06-191-1/+1
| | | | llvm-svn: 240163
* Fix ASAN bot; missing bookkeeping in r240136.Marshall Clow2015-06-191-0/+1
| | | | llvm-svn: 240139
* Fix PR#18843. Thanks to Howard for the fixMarshall Clow2015-06-191-1/+4
| | | | llvm-svn: 240136
* [libcxx] Fix detection of __is_final.Eric Fiselier2015-06-131-7/+2
| | | | | | | | | | | | | | Summary: Currently we only enable the use of __is_final(...) with Clang. GCC also provides __is_final(...) since 4.7 in all standard modes. This patch creates the macro _LIBCPP_HAS_IS_FINAL to note the availability of `__is_final`. Reviewers: danalbert, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8795 llvm-svn: 239664
* Implement the first part of N4258 - allocator_traits<X>::is_always_equal. ↵Marshall Clow2015-06-021-0/+28
| | | | | | Also fixes PR#23723 llvm-svn: 238848
* In the case where we are copying/moving zero elements, do less workMarshall Clow2015-06-021-2/+6
| | | | llvm-svn: 238828
* Remove debugging codeMarshall Clow2015-05-311-2/+0
| | | | llvm-svn: 238674
* Don't try to memcpy zero bytes; sometimes the source pointer is NULL, and ↵Marshall Clow2015-05-311-3/+8
| | | | | | that's UB. Thanks to Nuno Lopes for the catch. llvm-svn: 238666
* Fix PR#23647 - make_shared<volatile bool> - second tryMarshall Clow2015-05-271-1/+1
| | | | llvm-svn: 238370
* Revert 238354 while I figure out what broke in weak_ptrMarshall Clow2015-05-271-2/+2
| | | | llvm-svn: 238355
* Fix PR#23647 - make_shared<volatile bool>Marshall Clow2015-05-271-2/+2
| | | | llvm-svn: 238354
* Implement LWG2433: uninitialized_copy()/etc. should tolerate overloaded ↵Marshall Clow2015-05-191-7/+7
| | | | | | operator& llvm-svn: 237699
* Fix for LWG Issue 2415: Inconsistency between unique_ptr and shared_ptrMarshall Clow2015-05-101-9/+23
| | | | llvm-svn: 236953
* Fix for LWG2454: Add raw_storage_iterator::base() memberMarshall Clow2015-05-101-0/+3
| | | | llvm-svn: 236948
* In many places, there was an #ifdef/#else block that selected one of two ↵Marshall Clow2015-04-071-0/+10
| | | | | | 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
OpenPOWER on IntegriCloud