summaryrefslogtreecommitdiff
path: root/libcxx/include
Commit message (Collapse)AuthorAgeFilesLines
* [libc++] Disallow volatile types in std::allocatorJoe Loser2021-09-221-0/+2
| | | | | | | | | | | | | | | | LWG 2447 is marked as `Complete`, but there is no `static_assert` to reject volatile types in `std::allocator`. See the discussion at https://reviews.llvm.org/D108856. Add `static_assert` in `std::allocator` to disallow volatile types. Since this is an implementation choice, mark the binding test as `libc++` only. Remove tests that use containers backed by `std::allocator` that test the container when used with a volatile type. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D109056
* [libc++] Add some missing _LIBCPP_HIDE_FROM_ABI markupLouis Dionne2021-09-212-63/+102
| | | | | | | Also, as a fly-by fix, use `inline` directly to define inline variables (all compilers support it). Differential Revision: https://reviews.llvm.org/D110208
* [libcxx][AIX] Remove locale fallbacks for old OS levelsDavid Tenty2021-09-213-287/+1
| | | | | | | | | | These routines were add years ago during initial porting attempts to AIX and are mostly build hacks for routines which we're missing at the time, but are available now on recent AIX OS levels. Thus builds on modern AIX OS levels no longer need these and they cause problems if you try to build the library with a generic triple (i.e. powerpc-ibm-aix) as we'll pull them in and encounter duplicate definitions from the OS. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D110183
* [libc++] Surpress -Wunused-value warning in variantYuanfang Chen2021-09-211-1/+1
| | | | | The idiom helps with parameter unpacking so the return value is not important. Make it explicit.
* [libc++] counting_semaphore should not be default-constructible.Arthur O'Dwyer2021-09-211-3/+3
| | | | | | | | | | | | | | | | Neither the current C++2b draft, nor any revision of [p1135], nor libstdc++, claims that `counting_semaphore` should be default-constructible. I think this was just a copy-paste issue somehow. Also, `explicit` was missing from the constructor. Also, `constexpr` remains missing; but that's probably more of a technical limitation, since apparently there are some platforms where we don't (can't??) use the atomic implementation and have to rely on pthreads, which obviously isn't constexpr. Differential Revision: https://reviews.llvm.org/D110042
* [libc++][format] Adds parser std-format-spec.Mark de Wever2021-09-215-7/+733
| | | | | | | | | | | | | | | | | This implements the generic std.format.spec framework for all types. The Unicode support will be added in a separate patch. Implements parts of: - P0645 Text Formatting Completes: - LWG-3242 std::format: missing rules for arg-id in width and precision - P1892 Extended locale-specific presentation specifiers for std::format Reviewed By: #libc, ldionne, vitaut Differential Revision: https://reviews.llvm.org/D103368
* [libc++] [P0919] Some belated review on D87171.Arthur O'Dwyer2021-09-203-159/+153
| | | | | | | | | | | | - Simplify the structure of the new tests. - Test const containers as well as non-const containers, since it's easy to do so. - Remove redundant enable-iffing of helper structs' member functions. (They're not instantiated unless they're called, and who would call them?) - Fix indentation and use more consistent SFINAE method in <unordered_map>. - Add _LIBCPP_INLINE_VISIBILITY on some swap functions. Differential Revision: https://reviews.llvm.org/D109011
* [libc++] [LIBCXX-DEBUG-FIXME] Constexpr char_traits::copy mustn't compare ↵Arthur O'Dwyer2021-09-201-7/+19
| | | | | | | | | | unrelated pointers. Now that __builtin_is_constant_evaluated() is present on all supported compilers, we can use it to skip the UB-inducing assert in cases where the computation might be happening at constexpr time. Differential Revision: https://reviews.llvm.org/D101674
* Eliminate _LIBCPP_EQUAL_DELETE in favor of `=delete`.Arthur O'Dwyer2021-09-204-18/+12
| | | | | | | All supported compilers have supported `=delete` as an extension in C++03 mode for many years at this point. Differential Revision: https://reviews.llvm.org/D109942
* [SystemZ][z/OS] Missing wchar functions libc++Muiez Ahmed2021-09-131-3/+3
| | | | | | The aim is to add the missing z/OS specific implementations for mbsnrtowcs and wcsnrtombs, as part of libc++. Differential Revision: https://reviews.llvm.org/D98207
* [libc++] Add missing short wchar handling for codecvt_utf8, codecvt_utf16 ↵Xing Xue2021-09-091-0/+5
| | | | | | | | | | | | | | | | and codecvt_utf8_utf16 Summary: AIX have 2 byte wchar in 32 bit mode and 4 byte wchar in 64 bit mode. This patch add more missing short wchar handling under the existing _LIBCPP_SHORT_WCHAR macro. Marked test case ctor_move.pass.cpp as XFAIL for 32-bit mode on AIX because UTF-8 constants used cannot be converted to 2-byte wchar (by xingxue). Authored by: jasonliu Reviewed by: ldionne, zibi, SeanP, libc++ Differential Revision: https://reviews.llvm.org/D100777
* [libc++][NFC] Add #endif comment for long #if-#endif blockLouis Dionne2021-09-091-1/+1
|
* [libc++][NFC] Move __char_traits_length_checked outside of wchar_t definitionsLouis Dionne2021-09-091-12/+10
| | | | This will simplify an upcoming diff.
* [libc++][NFC] Remove #endif comments for really small conditionals on ↵Louis Dionne2021-09-094-4/+4
| | | | | | | _LIBCPP_HAS_NO_UNICODE_CHARS We generally don't put a comment on the #endif when the #if block is so small that it's unambiguous what the #endif refers to.
* [libc++] Implement C++20's P0476R2: std::bit_castLouis Dionne2021-09-095-2/+49
| | | | | | Thanks to Arthur O'Dwyer for fixing up some of the tests. Differential Revision: https://reviews.llvm.org/D75960
* [libc++] Implement P1951, default arguments for pair's forwarding constructorLouis Dionne2021-09-092-4/+3
| | | | Differential Revision: https://reviews.llvm.org/D109066
* [libc++][NFC] Rename _EnableIf to __enable_if_t for consistencyLouis Dionne2021-09-0816-179/+179
| | | | | | | In other places in the code, we use lowercase spelling for things that are not available in prior standards. Differential Revision: https://reviews.llvm.org/D109435
* [libc++] Comma-operator-proof a lot of algorithm/container code.Arthur O'Dwyer2021-09-088-25/+25
| | | | | | | | | | | | | | | Detected by evil-izing the widely used `MoveOnly` testing type. I had to patch some tests that were themselves using its comma operator, but I think that's a worthwhile cost in order to catch more places in our headers that needed comma-proofing. The trick here is that even `++ptr, SomeClass()` can find a comma operator by ADL, if `ptr` is of type `Evil*`. (A comma between two operands of non-class-or-enum type is always treated as the built-in comma, without ADL. But if either operand is class-or-enum, then ADL happens for _both_ operands' types.) Differential Revision: https://reviews.llvm.org/D109414
* [libc++] Use enable_if_t instead of _EnableIfLouis Dionne2021-09-0821-231/+229
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I just ran into a compiler error involving __bind_back and some overloads that were being disabled with _EnableIf. I noticed that the error message was quite bad and did not mention the reason for the overload being excluded. Specifically, the error looked like this: candidate template ignored: substitution failure [with _Args = <ContiguousView>]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>' Instead, when using enable_if or enable_if_t, the compiler is clever and can produce better diagnostics, like so: candidate template ignored: requirement 'is_invocable_v< std::__bind_back_op<1, std::integer_sequence<unsigned long, 0>>, std::ranges::views::__transform::__fn &, std::tuple<PlusOne> &, ContiguousView>' was not satisfied [with _Args = <ContiguousView>] Basically, it tries to do a poor man's implementation of concepts, which is already a lot better than simply complaining about substitution failure. Hence, this commit uses enable_if_t instead of _EnableIf whenever possible. That is both more straightforward than using the internal helper, and also leads to better error messages in those cases. I understand the motivation for _EnableIf's implementation was to improve compile-time performance, however I believe striving to improve error messages is even more important for our QOI, hence this patch. Furthermore, it is unclear that _EnableIf actually improved compile-time performance in any noticeable way (see discussion in the review for details). Differential Revision: https://reviews.llvm.org/D108216
* [libc++][NFC] Add missing synopsis for node handlesLouis Dionne2021-09-071-0/+48
| | | | This was manually taken from https://llvm.org/D100311.
* [libc++] Remove a stray `const` on ranges::data and ranges::ssize. NFCI.Arthur O'Dwyer2021-09-072-2/+2
| | | | | | | | These are specced as `inline constexpr auto`; the extra `const` isn't doing anything except being inconsistent with the other CPOs. Now all the implemented CPOs can be detected by git grep 'inline constexpr auto.*fn' ../libcxx/include/ and I think that's beautiful.
* [libc++] Fix std::to_address(array).Arthur O'Dwyer2021-09-071-1/+9
| | | | | | | | | | | | | | | | | | | | | There were basically two bugs here: When C++20 `to_address` is called on `int arr[10]`, then `const _Ptr&` becomes a reference to a const array, and then we dispatch to `__to_address<const int(&)[10]>`, which, oops, gives us a `const int*` result instead of an `int*` result. Solution: We need to provide the two standard-specified overloads of `std::to_address` in exactly the same way that we provide two overloads of `__to_address`. When `__to_address` is called on a pointer type, `__to_address(const _Ptr&)` is disabled so we successfully avoid trying to instantiate pointer_traits of that pointer type. But when it's called on an array type, it's not disabled for array types, so we go ahead and instantiate pointer_traits<int[10]>, which goes boom. Solution: We need to disable `__to_address(const _Ptr&)` for both pointer and array types. Also disable it for function types, so that they get the nice error message; and put a test on it. Differential Revision: https://reviews.llvm.org/D109331
* [libc++][compare] Implement three_way_comparable[_with] conceptsRuslan Arutyunyan2021-09-054-0/+67
| | | | | | | | | | | | | | Implementation of `three_way_comparable` and `three_way_comparable_with` concepts from <compare> header. Please note that I have temporarily removed `<compare>` header from `<utility>` due to cyclic dependency that prevents using `<concepts>` header in `<compare>` one. I tried to quickly resolve those issues including applying suggestions from @cjdb and dive deeper by myself but the problem seems more complicated that we thought initially. I am in progress to prepare the patch with resolving this cyclic dependency between headers but for now I decided to put all that I have to the review to unblock people that depend on that functionality. At first glance the patch with resolving cyclic dependency is not so small (unless I find the way to make it smaller and cleaner) so I don't want to mix everything to one review. Reviewed By: ldionne, cjdb, #libc, Quuxplusone Differential Revision: https://reviews.llvm.org/D103478
* [libc++][format] Implement formatters.Mark de Wever2021-09-045-0/+929
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the initial version of the `std::formatter` class and its specializations. It also implements the following formatting functions: - `format` - `vformat` - `format_to` - `vformat_to` - `format_to_n` - `formatted_size` All functions have a `char` and `wchar_t` version. Parsing the format-spec and using the parsed format-spec hasn't been implemented. The code isn't optimized, neither for speed, nor for size. The goal is to have the rudimentary basics working, which can be used as a basis to improve upon. The formatters used in this commit are simple stubs that will be replaced by real formatters in later commits. The formatters that are slated to be replaced in this patch series don't have an availability macro to avoid merge conflicts. Note the formatter for `bool` uses `0` and `1` instead of "false" and "true". This will be fixed when the stub is replaced with a real formatter. Implements parts of: - P0645 Text Formatting Completes: - LWG3539 format_to must not copy models of output_iterator<const charT&> Reviewed By: ldionne, #libc, vitaut Differential Revision: https://reviews.llvm.org/D96664
* [libc++] Add an assertion in the subrange constructors with a size hintLouis Dionne2021-09-031-2/+8
| | | | | | | | | | Those constructors are very easy to misuse -- one could easily think that the size passed to the constructor is the size of the range to exhibit from the subrange. Instead, it's a size hint and it's UB to get it wrong. Hence, when it's cheap to compute the real size of the range, it's cheap to make sure that the user didn't get it wrong. Differential Revision: https://reviews.llvm.org/D108827
* [libc++] Remove _LIBCPP_HAS_NO_LONG_LONG in favour of using_if_existsLouis Dionne2021-09-034-31/+18
| | | | | | | | | | | _LIBCPP_HAS_NO_LONG_LONG was only defined on FreeBSD. Instead, use the using_if_exists attribute to skip over declarations that are not available on the base system. Note that there's an annoying limitation that we can't conditionally define a function based on whether the base system provides a function, so for example we still need preprocessor logic to define the abs() and div() overloads. Differential Revision: https://reviews.llvm.org/D108630
* [libc++] Define insert_iterator::iter with ranges::iterator_t.Arthur O'Dwyer2021-09-021-3/+12
| | | | | | | | | | | The `insert_iterator::iter` member is defined as `Container::iterator` but the standard requires `iter` to be defined in terms of `ranges::iterator_t` as of C++20. So, if in C++20 or later, define the `iter` member as `ranges::iterator_t`. Original patch by Joe Loser! Differential Revision: https://reviews.llvm.org/D108575
* [libc++] Remove an unused internal concept.Mark de Wever2021-09-021-2/+0
| | | | Removed as suggested by @Quuxplusone during the review of D109075.
* [libc++][NFC] Move concepts to a subheader.Mark de Wever2021-09-024-22/+10
| | | | | | | | | | D103357 added some new concepts. Since the header `<concepts>` has moved all its concepts to a separate header these new concepts feel out of place. Move them to the appropriate header. Reviewed By: #libc, Quuxplusone, ldionne Differential Revision: https://reviews.llvm.org/D109075
* [libc++][nfc] Fixes ppc64le-sanitizer build issue.Mark de Wever2021-09-021-5/+5
| | | | | After landing D103357 the worker ppc64le-sanitizer fails on `__bool`. This replaces all occurrences with `__boolean`.
* [libc++][format] Add __format_arg_store.Mark de Wever2021-09-0110-7/+760
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the struct `__format_arg_store` and its dependencies: * the class basic_format_arg, * the class basic_format_args, * the class basic_format_context, * the function make_format_args, * the function wmake_format_args, * the function visit_format_arg, * several Standard required typedefs. The following parts will be implemented in a later patch: * the child class `basic_format_arg::handle`, * the function `basic_format_arg::basic_format_arg(const T* p)`. The following extension has been implemented: * the class basic_format_arg supports `__[u]int128_t` on platform where libc++ supports 128 bit integrals. Implements parts of: * P0645 Text Formatting Completes: * LWG3371 visit_format_arg and make_format_args are not hidden friends * LWG3542 basic_format_arg mishandles basic_string_view with custom traits Note https://mordante.github.io/blog/2021/06/05/format.html gives a bit more information about the goals and non-goals of this initial patch series. Reviewed By: #libc, ldionne, vitaut Differential Revision: https://reviews.llvm.org/D103357
* [libc++] Remove some workarounds for unsupported GCC and Clang versionsLouis Dionne2021-09-017-245/+7
| | | | | | | | There is a lot more we can do, in particular in <type_traits>, but this removes some workarounds that were gated on checking a specific compiler version. Differential Revision: https://reviews.llvm.org/D108923
* [libc++] Remove workarounds for [[nodebug]] not working properly on typedefs ↵Louis Dionne2021-09-0118-170/+164
| | | | | | | | | | in older Clangs Clang used to support [[nodebug]] everywhere except on typedefs. Since we don't support such old Clangs anymore, we can get rid of _LIBCPP_NODEBUG_TYPE in favour of always using _LIBCPP_NODEBUG. Differential Revision: https://reviews.llvm.org/D108996
* [libc++][NFC] Use std::enable_if instead of _EnableB helper in pairLouis Dionne2021-09-011-29/+26
| | | | | This doesn't impact the compile-time efficiency, but we get better diagnostics when an overload is disabled.
* [libcxx] contiguous iterator concept: don't require pointer or complete ↵Joe Loser2021-09-011-1/+0
| | | | | | | | | | | | | | | | element types `contiguous_iterator` requires the iterator type passed is either a pointer type or that the element type of the iterator is a complete object type. These constraints are not part of the current wording in defining the `contiguous_iterator` concept - adjust the concept to reflect this. Inspired from discussion at https://reviews.llvm.org/D108645. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D108855
* [libc++][NFC] Remove redundant friend declaration for operator==Louis Dionne2021-08-311-6/+0
| | | | | | | | This must have been meant to be friend-declaring operator!=, but it turns out that it's not even necessary to make it a friend since it does not access any private state. rdar://82568613
* [libc++][NFC] Rename _LIBCPP_NODISCARD_ATTRIBUTE to _LIBCPP_NODISCARDLouis Dionne2021-08-312-8/+6
| | | | Differential Revision: https://reviews.llvm.org/D108940
* [libc++] Remove workaround for broken __is_trivially_copyable on old GCCLouis Dionne2021-08-311-6/+0
| | | | | | All supported versions of GCC now do the right thing. Differential Revision: https://reviews.llvm.org/D108997
* [libc++] Add missing space in (__map_value_compare&__y) etc. NFCI.Arthur O'Dwyer2021-08-313-8/+8
|
* [libc++][NFC] split <charconv>.Mark de Wever2021-08-316-62/+158
| | | | | | | | | | | | | | | This move the helper types `chars_format`, `to_chars_result` and `from_chars_result` to a separate header. The first two are needed for D70631 the third for consistency. The header `__charconv/ryu.h` uses these types and it can't depend on the types in `<charconv>` in a modular build. Moving them to the ryu header would be an odd place and doesn't work since the header is included in the middle of `<charconv>`. Reviewed By: #libc, ldionne, Quuxplusone Differential Revision: https://reviews.llvm.org/D108927
* [libc++][NFC] Add missing HIDE_FROM_ABI on implementation detail __launderLouis Dionne2021-08-311-3/+2
|
* [libcxx] Remove the locale fallback for NuttXXiang Xiao2021-08-313-21/+0
| | | | | | | | Since these functions can handled by NuttX's libc now Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D108895
* [libc++][NFC] Fix include guard for decay_copy.h and remove underscores from ↵Louis Dionne2021-08-279-11/+11
| | | | | | | | | the header We don't use double underscores for private header names when they are in a subdirectory with double underscores already. Differential Revision: https://reviews.llvm.org/D108820
* [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROSLouis Dionne2021-08-27179-905/+0
| | | | | | Only files that actually use min/max are required to do this dance. Differential Revision: https://reviews.llvm.org/D108778
* [libc++][NFC] Remove extra __ranges/take_view.h entry in CMakeLists.txtJoe Loser2021-08-271-1/+0
| | | | Differential Revision: https://reviews.llvm.org/D108802
* [libc++][NFC] Sort headers alphabeticallyLouis Dionne2021-08-262-4/+4
|
* [libc++] Implement the underlying mechanism for range adaptorsLouis Dionne2021-08-265-6/+117
| | | | | | | | | | This patch implements the underlying mechanism for range adaptors. It does so based on http://wg21.link/p2387, even though that paper hasn't been adopted yet. In the future, if p2387 is adopted, it would suffice to rename `__bind_back` to `std::bind_back` and `__range_adaptor_closure` to `std::range_adaptor_closure` to implement that paper by the spec. Differential Revision: https://reviews.llvm.org/D107098
* [libc++] Fix incorrect bypassing of <wctype.h>Louis Dionne2021-08-262-0/+12
| | | | Differential Revision: https://reviews.llvm.org/D108709
* [libc++] Revert a use of `static_cast` for `_VSTD::forward`. NFCI.Arthur O'Dwyer2021-08-261-1/+2
| | | | | | As requested in D107584. Differential Revision: https://reviews.llvm.org/D108743
* [libc++][NFC] Remove duplicate ranges entry in CMakeLists.txt.Dimitry Andric2021-08-251-1/+0
| | | | | | | | The second entry got added accidentally as part of 5a3309f825769. Reviewed By: cjdb Differential Revision: https://reviews.llvm.org/D108726