summaryrefslogtreecommitdiffstats
path: root/libcxx/include
Commit message (Collapse)AuthorAgeFilesLines
...
* Add '_LIBCPP_ASSERT(ready())' to several match_results method that have this ↵Marshall Clow2019-04-261-6/+27
| | | | | | precondtion. Fix several tests which did not honor this precondition. Thanks to Andrey Maksimov for pointing this out. llvm-svn: 359324
* Fix return type of std::tuple_cat.Eric Fiselier2019-04-261-2/+2
| | | | | | | | | | | | When the arguments to tuple cat were const, the const was incorrectly propagated into the type of the resulting tuple. For example: const std::tuple<int> t(42); auto r = std::tuple_cat(t, t); // Incorrect! should be std::tuple<int, int>. static_assert(is_same_v<decltype(r), std::tuple<const int, const int>>); llvm-svn: 359255
* Remove incorrect explicit instantiation declarations for valarrayRichard Smith2019-04-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | libc++ ABI v1 provides three valarray symbols as part of the shared library: valarray<size_t>::valarray(size_t) valarray<size_t>::~valarray() valarray<size_t>::resize(size_t, size_t) The first two of these are intended to be removed in V2 of the ABI: they're attributed _LIBCPP_HIDE_FROM_ABI_AFTER_V1, and it appears that the intention is that these symbols from the library are not used even when building using the V1 ABI. However, there are explicit instantiation declarations for all three symbols in the header, which are not correct as we do not intend to find an instantiation of these functions that is provided elsewhere. (A recent change to clang to properly diagnose explicit instantiation declarations of internal linkage functions -- required by [temp.explicit]p13 -- had to be rolled back because it diagnosed these explicit instantiations.) Remove the explicit instantiation declarations, and remove the explicit instantiation definitions for V2 of the libc++ ABI onwards. llvm-svn: 359243
* Remove libc++ checks and workarounds for unsupported old versions of GCC (<4.9).Richard Smith2019-04-253-68/+39
| | | | | | Differential Revision: https://reviews.llvm.org/D61107 llvm-svn: 359232
* Fix buildbot failures after r359159.Richard Smith2019-04-251-1/+1
| | | | | | | | | | | | | std::mutex was not actually is_nothrow_default_constructible in C++98/C++03, because the variable declaration std::mutex M; ... could throw an exception from the mutex destructor. Fix it by marking the destructor as non-throwing. This has no effect in C++11 onwards, because destructors are non-throwing by default in those language modes. llvm-svn: 359229
* Set _LIBCPP_DLL_VIS on _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS in MinGW modeMartin Storsjo2019-04-251-2/+7
| | | | | | | | | | Contrary to MSVC, MinGW compilers wants the dllexport attribute on the declaration of an explicit template instantiation, not on the definition. Differential Revision: https://reviews.llvm.org/D61123 llvm-svn: 359227
* Implement 'lerp'; which is the last bit of P0811. Mark that paper as complete.Marshall Clow2019-04-251-0/+27
| | | | llvm-svn: 359211
* Implement midpoint for floating point types. Reviewed as ↵Marshall Clow2019-04-252-1/+21
| | | | | | https://reviews.llvm.org/D61014. llvm-svn: 359184
* Use modern type trait implementations when available.Richard Smith2019-04-251-14/+39
| | | | | | | | | | | | | | Teach libcxx to stop using various deprecated __has_* type traits, in favor of the ("modern", C++11 era) __is_* type traits. This is mostly just a simplification, but fixes at least one bug: _Atomic T should be considered trivially-destructible, but is not considered to be POD by Clang, and __has_trivial_destructor is specified in the GCC documentation as returning false for non-POD non-class types. Differential Revision: https://reviews.llvm.org/D48292 llvm-svn: 359159
* Add std::is_constant_evaluated.Eric Fiselier2019-04-243-1/+14
| | | | | | | | | Clang recently added __builtin_is_constant_evaluated() and GCC 9.0 has it as well. This patch adds support for it in libc++. llvm-svn: 359119
* Avoid name conflict with kernel headersEric Fiselier2019-04-243-9/+9
| | | | llvm-svn: 359080
* Fix implementation of ::abs and std::abs LWG 2192.Eric Fiselier2019-04-232-37/+59
| | | | | | | | | | | | | | | | | | | Summary: All overloads of `::abs` and `std::abs` must be present in both `<cmath>` and `<cstdlib>`. This is problematic to implement because C defines `fabs` in `math.h` and `labs` in `stdlib.h`. This introduces a circular dependency between the two headers. This patch implements that requirement by moving `abs` into `math.h` and making `stdlib.h` include `math.h`. In order to get the underlying C declarations from the "real" `stdlib.h` inside our `math.h` we need some trickery. Specifically we need to make `stdlib.h` include next itself. Suggestions for a cleaner implementation are welcome. Reviewers: mclow.lists, ldionne Reviewed By: ldionne Subscribers: krytarowski, fedor.sergeev, dexonsmith, jdoerfert, jsji, libcxx-commits Differential Revision: https://reviews.llvm.org/D60097 llvm-svn: 359020
* [libc++] Make __debug_less::operator() constexprThomas Anderson2019-04-191-0/+1
| | | | | | | | | | | | | | This is a followup to [1] which added a new `__debug_less::operator()` overload. [2] added `_LIBCPP_CONSTEXPR_AFTER_CXX17` to the original `__debug_less::operator()` between the time of writing [1] and landing it. This change adds `_LIBCPP_CONSTEXPR_AFTER_CXX17` to the new overload too. [1] https://reviews.llvm.org/rL358423 [2] https://reviews.llvm.org/rL358252 Differential Revision: https://reviews.llvm.org/D60724 llvm-svn: 358725
* [libc++] Unconditionally enable the __pad_and_output optimizationLouis Dionne2019-04-182-11/+0
| | | | | | | | | | This used to be guarded on whether the deployment target was greater than macosx10.8, however testing against the dylibs for 10.8 and earlier with the function enabled works too. The revision that introduced __pad_and_output is r164241 and it does not mention a reason for the guard. llvm-svn: 358677
* [libc++] Use the no_destroy attribute to avoid destroying debug DB staticsLouis Dionne2019-04-171-0/+6
| | | | | | | | | | | | | | | | | Summary: Otherwise, we can run into problems when the program has static variables that need to use the debug database during their deinitialization, if the debug DB has already been deinitialized. Reviewers: EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D60830 llvm-svn: 358602
* Fix visibility for coroutine types on WindowsEric Fiselier2019-04-171-3/+3
| | | | llvm-svn: 358551
* Fix list/forward_list implementations of remove_if and unique to deal with ↵Marshall Clow2019-04-162-6/+13
| | | | | | predicates that are part of the sequence passed in. We already do this for remove. llvm-svn: 358534
* [libc++] Fix build failure with _LIBCPP_DEBUG=0 when iterators return values ↵Thomas Anderson2019-04-151-0/+9
| | | | | | | | | | | | | | | | | | | instead of references There are many STL algorithms (such as lexicographical_compare) that compare values pointed to by iterators like so: __comp(*it1, *it2); When building with `_LIBCPP_DEBUG=0`, comparators are wrapped in `__debug_less` which does some additional validation. But `__debug_less::operator()` takes non-const references, so if the type of `*it1` is int, not int&, then the build will fail. This change adds a `const&` overload for `operator()` to fix the build. Differential Revision: https://reviews.llvm.org/D60592 llvm-svn: 358423
* Cleanup how debug comparators are created in <algorithm>Eric Fiselier2019-04-121-151/+38
| | | | | | | | | | Instead of having an `#if` block in every algorithm using a debug comparator, this patch introduces the __comp_ref_type trait that selects __debug_less in debug mode and _Comp& otherwise. This patch should have no observable functionality change. llvm-svn: 358252
* [libc++] Make sure we don't eagerly diagnose non-const comparators for ↵Louis Dionne2019-04-116-15/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | containers of incomplete types Summary: In r348529, I improved the library-defined diagnostic for using containers with a non-const comparator/hasher. However, the check is now performed too early, which leads to the diagnostic being emitted in cases where it shouldn't. See PR41360 for details. This patch moves the diagnostic to the destructor of the containers, which means that the diagnostic will only be emitted when the container is instantiated at a point where the comparator and the key/value are required to be complete. We still retain better diagnostics than before r348529, because the diagnostics are performed in the containers themselves instead of __tree and __hash_table. As a drive-by fix, I improved the diagnostic to mention that we can't find a _viable_ const call operator, as suggested by EricWF in PR41360. Reviewers: EricWF, mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits, zoecarver Tags: #libc Differential Revision: https://reviews.llvm.org/D60540 llvm-svn: 358189
* [libc++] Fix error flags and exceptions propagated from input stream operationsLouis Dionne2019-04-052-374/+518
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a re-application of r357533 and r357531. They had been reverted because we thought the commits broke the LLDB data formatters, but it turns out this was because only r357531 had been included in the CI run. Before this patch, we would only ever throw an exception if the badbit was set on the stream. The Standard is currently very unclear on how exceptions should be propagated and what error flags should be set by the input stream operations. This commit changes libc++ to behave under a different (but valid) interpretation of the Standard. This interpretation of the Standard matches what other implementations are doing. This effectively implements the wording in p1264r0. It hasn't been voted into the Standard yet, however there is wide agreement that the fix is correct and it's just a matter of time before the fix is standardized. PR21586 PR15949 rdar://problem/15347558 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D49863 llvm-svn: 357775
* libcxx: Add _LIBCPP_NODISCARD_EXT to 38 more functionsNico Weber2019-04-031-77/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This builds on the work done in r342808 and adds _LIBCPP_NODISCARD_EXT to 37 more functions, namely: adjacent_find, all_of, any_of, binary_search, clamp, count_if, count, equal_range, equal, find_end, find_first_not_of, find_first_of, find_if, find, includes, is_heap_until, is_heap, is_partitioned, is_permutation, is_sorted_until, is_sorted, lexicographical_compare, lower_bound, max_element, max, min_element, min, minmax_element, minmax, mismatch, none_of, remove_if, remove, search_n, search, unique, upper_bound The motivation here is that we noticed that find_if is nodiscard with Visual Studio's standard library, and we deemed that useful (https://crbug.com/948122). https://devblogs.microsoft.com/cppblog/c17-progress-in-vs-2017-15-5-and-15-6/ says "Our criteria for emitting the warning are: discarding the return value is a guaranteed leak [...], discarding the return value is near-guaranteed to be incorrect (e.g. remove()/remove_if()/unique()), or the function is essentially a pure observer (e.g. vector::empty() and std::is_sorted())." so I went through algorithm and tried to apply these criteria. Some of these, like vector::empty() are already nodiscard per C++ standard and didn't need changing. I didn't (yet?) go over std::string::find* methods which should probably have _LIBCPP_NODISCARD_EXT too (but not as part of this change). Differential Revision: https://reviews.llvm.org/D60145 llvm-svn: 357619
* [libc++] Use std::is_nothrow_callable for std::invoke according to LWG 2807Louis Dionne2019-04-031-2/+6
| | | | | | | Thanks to Zoe Carver for the patch. Differential Revision: https://reviews.llvm.org/D58097 llvm-svn: 357616
* [libc++] (Take 2) Correctly handle Objective-C++ ARC qualifiers in ↵Louis Dionne2019-04-031-1/+9
| | | | | | | | | | | | | | | | | | | | | std::is_pointer Summary: Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak> (and others) don't work as expected. The previous patch (r357517) had to be reverted in r357569 because it broke the Chromium build. This patch shouldn't have the same problem. rdar://problem/49126333 Reviewers: ahatanak, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D60087 llvm-svn: 357586
* Revert "[libc++] Correctly handle Objective-C++ ARC qualifiers in ↵Hans Wennborg2019-04-031-5/+0
| | | | | | | | | | | | | | | | | | | | std::is_pointer" This broke the Chromium build on Mac, see https://crbug.com/949071 > Summary: > Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak> > (and others) don't work as expected. > > rdar://problem/49126333 > > Reviewers: ahatanak, EricWF > > Subscribers: christof, jkorous, dexonsmith, libcxx-commits > > Differential Revision: https://reviews.llvm.org/D60087 llvm-svn: 357569
* Fix backwards test that I committed yesterday. SighMarshall Clow2019-04-031-2/+2
| | | | llvm-svn: 357540
* Revert "[libc++] Fix error flags and exceptions propagated from input stream ↵Louis Dionne2019-04-022-518/+374
| | | | | | | | | | operations" This reverts commits r357533 and r357531, which broke the LLDB data formatters. I'll hold off until we know how to fix the data formatters accordingly. llvm-svn: 357536
* [libc++] Fix build when exceptions are turned offLouis Dionne2019-04-021-1/+1
| | | | llvm-svn: 357533
* [libc++] Fix error flags and exceptions propagated from input stream operationsLouis Dionne2019-04-022-374/+518
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this patch, we would only ever throw an exception if the badbit was set on the stream. The Standard is currently very unclear on how exceptions should be propagated and what error flags should be set by the input stream operations. This commit changes libc++ to behave under a different (but valid) interpretation of the Standard. This interpretation of the Standard matches what other implementations are doing. I will submit a paper in San Diego to clarify the Standard such that the interpretation used in this commit (and other implementations) is the only possible one. PR21586 PR15949 rdar://problem/15347558 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D49863 llvm-svn: 357531
* [libc++] Correctly handle Objective-C++ ARC qualifiers in std::is_pointerLouis Dionne2019-04-021-0/+5
| | | | | | | | | | | | | | | | Summary: Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak> (and others) don't work as expected. rdar://problem/49126333 Reviewers: ahatanak, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D60087 llvm-svn: 357517
* [libc++] Remove use of auto with actual typeLouis Dionne2019-04-021-2/+2
| | | | | | For compatibility with C++03. llvm-svn: 357512
* [libc++][NFC] Remove useless public: label at the end of classLouis Dionne2019-04-021-1/+0
| | | | llvm-svn: 357511
* Special case some duration arithmetic for GCC and PPC because their long ↵Marshall Clow2019-04-021-0/+5
| | | | | | double constant folding is broken. Fixes PR#39696. llvm-svn: 357478
* Fix a number of bugs in __val_expr's subset operator[].Eric Fiselier2019-04-021-4/+19
| | | | | | | | The current definitions were entirely broken. They didn't call any existing constructor and the forgot to friend the expression types they were trying to construct. llvm-svn: 357453
* [libc++] Declare std::tuple_element as struct instead of classLouis Dionne2019-04-015-24/+15
| | | | | | | | | | | | Similarly to https://reviews.llvm.org/rL350972, this revision changes std::tuple_element from class to struct. Fixes PR41331. Thanks to Jan Wilken Dörrie for the patch. Differential Revision: https://reviews.llvm.org/D60069 llvm-svn: 357411
* Fix PR41130 - 'operator/ of std::chrono::duration and custom type'. Thanks ↵Marshall Clow2019-04-011-26/+12
| | | | | | to Zulan for the report, and Howard for the direction of the fix. llvm-svn: 357410
* Make common_type's implementation common Eric Fiselier2019-03-311-75/+56
| | | | | | | | | | | | | | | | | | | Summary: Currently the C++03 implementation of common_type has much different behavior than the C++11 one. This causes bugs, including inside `<chrono>`. This patch unifies the two implementations as best it can. The more code they share, the less their behavior can diverge. Reviewers: mclow.lists, ldionne, sbenza Reviewed By: mclow.lists, ldionne Subscribers: libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D59678 llvm-svn: 357370
* Mark fenv.h as a system header before the #include_next directiveEric Fiselier2019-03-291-1/+2
| | | | | | | | This fixes a -Wgnu-include-next warning Patch by dmauro. llvm-svn: 357267
* Fix PR#35967: '<regex> syntax_option_type is not a proper bitmask' Sadly, ↵Marshall Clow2019-03-282-12/+46
| | | | | | this is an ABI break, so it's only available if you define either '_LIBCPP_ABI_VERSION > 2' or '_LIBCPP_ABI_UNSTABLE' or '_LIBCPP_ABI_REGEX_CONSTANTS_NONZERO' and rebuild your dylib. llvm-svn: 357190
* [libc++] Rename span's as_writeable_bytes to as_writable_bytesLouis Dionne2019-03-281-6/+6
| | | | | | | | | | | | Summary: The Standard says as_writable_bytes. Reviewers: mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D59882 llvm-svn: 357139
* Fix and speedup __libcpp_locale_guard on WindowsThomas Anderson2019-03-271-19/+33
| | | | | | | | | | | | | | The old implementation assumed the POSIX `setlocale()` API where the old locale is returned. On Windows, the _new_ locale is returned. This meant that `__libcpp_locale_guard` wasn't resetting the locale on destruction. The new implementation fixes the above issue and takes advantage of `setlocale(LC_ALL)` to reduce the number of calls, and also avoids setting the locale at all if it's not necessary. Differential Revision: https://reviews.llvm.org/D59572 llvm-svn: 357104
* Revert "[coroutines] Add std::experimental::task<T> type"Brian Gesiak2019-03-265-515/+8
| | | | | | | | This revision is causing build and test failures, such as http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-armv8-linux/builds/648/steps/test.libcxx/logs/stdio, so I'll revert it. llvm-svn: 357023
* [coroutines] Add std::experimental::task<T> typeBrian Gesiak2019-03-265-8/+515
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds the coroutine `std::experimental::task<T>` type described in proposal P1056R0. See https://wg21.link/P1056R0. This implementation allows customization of the allocator used to allocate the coroutine frame by passing std::allocator_arg as the first argument, followed by the allocator to use. This supports co_awaiting the same task multiple times. The second and subsequent times it returns a reference to the already-computed value. This diff also adds some implementations of other utilities that have potential for standardization as helpers within the test/... area: - `sync_wait(awaitable)` - See P1171R0 - `manual_reset_event` Move the definition of the __aligned_allocation_size helper function from <experimental/memory_resource> to <experimental/__memory> so it can be more widely used without pulling in memory_resource. Outstanding work: - Use C++14 keywords directly rather than macro versions eg. use `noexcept` instead of `_NOEXCEPT`). - Add support for overaligned coroutine frames. This may need wording in the Coroutines TS to support passing the extra `std::align_val_t`. - Eliminate use of `if constexpr` if we want it to compile under C++14. Patch by @lewissbaker (Lewis Baker). llvm-svn: 357010
* Cleaup of requirements for optional. While researching LWG3196, I realized ↵Marshall Clow2019-03-251-1/+3
| | | | | | that optional did not reject 'const in_place_t' like it should. Added a test as well, and a check for arrays (which were already disallowed, but now we get a better error message). Should not affect anyone's code. llvm-svn: 356918
* Fix a minor bug with std::next and prev not and negative numbers. In ↵Marshall Clow2019-03-221-5/+12
| | | | | | particular, std::prev cannot require Bidirectional Iterators, because you might 'go back' -1 places, which goes forward. Thanks to Ville and Jonathan for the bug report. llvm-svn: 356818
* Remove type visibility specifiers from new chrono types.Eric Fiselier2019-03-211-18/+18
| | | | | | | | | _LIBCPP_TYPE_VIS is only really needed on types with a vtable. And on Windows it doesn't work with types that have only inline methods. This patch removes the unneeded attributes. llvm-svn: 356637
* libc++/win: Make once_flag have the same size as a pointer.Nico Weber2019-03-201-5/+14
| | | | | | | | | | | | | | | | | | | | | | `unsigned long` is 32-bit on 32-bit systems and 64-bit on 64-bit systems on LP64 systems -- which most Unix systems are, but Windows isn't. Windows is LLP64, which means unsigned long is 32-bit even on 64-bit systems. pplwin.h contains static_assert(alignof(void *) == alignof(::std::once_flag), ...) which fails due to this problem. Instead of unsigned long, use uintptr_t, which consistently is 32-bit on 32-bit systems and 64-bit on 64-bit systems. No functional change except on 64-bit Windows. Differential Revision: https://reviews.llvm.org/D59607 llvm-svn: 356624
* [libc++] Mark <filesystem> as unavailable on Apple platforms using pragmasLouis Dionne2019-03-203-3/+26
| | | | | | | | | | | | | | | | | | | | | Summary: Also add the corresponding XFAILs to tests that require filesystem. The approach taken to mark <filesystem> as unavailable in this patch is to mark all the header as unavailable using #pragma clang attribute. Marking each declaration using the attribute is more intrusive and does not provide a lot of value right now because pretty much everything in <filesystem> requires dylib support, often transitively. This is an alternative to https://reviews.llvm.org/D59093. A similar (but partial) patch was already applied in r356558. Reviewers: mclow.lists, EricWF, serge-sans-paille Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D59224 llvm-svn: 356616
* Make to_chars/from_chars work back to C++11. This means that we can use them ↵Marshall Clow2019-03-201-17/+17
| | | | | | to implement to_string as well. Reviewed as https://reviews.llvm.org/D59598. llvm-svn: 356585
* [NFC] Fix a couple of typos in libc++'s __configLouis Dionne2019-03-201-4/+4
| | | | llvm-svn: 356574
OpenPOWER on IntegriCloud