aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/utilities
AgeCommit message (Collapse)AuthorFilesLines
4 days[libc++][test] Guard non-guaranteed implicit-lifetime-ness cases with ↵A. Jiang1-0/+11
`_LIBCPP_VERSION` (#160627) And add some guaranteed cases (namely, for `expected`, `optional`, and `variant`) to `is_implicit_lifetime.pass.cpp`. It's somehow unfortunate that `pair` and `tuple` are not guaranteed to propagate triviality of copy/move constructors, and MSVC STL fails to do so due to ABI compatibility. This affects the implicit-lifetime property.
7 days[libc++] Implement Resolution of LWG 3886 (#155356)William Tran-Viet5-1/+92
Resolves #118336 - Implement the resolution of [LWG3886](https://cplusplus.github.io/LWG/issue3886) for `optional` and `expected`
2025-09-04[libc++][NFC] Use llvm.org/PR to link to bug reports (#156288)Nikolas Klauser97-102/+101
We've built up quite a few links directly to github within the code base. We should instead use `llvm.org/PR<issue-number>` to link to bugs, since that is resilient to the bug tracker changing in the future. This is especially relevant for tests linking to bugs, since they will probably be there for decades to come. A nice side effect is that these links are significantly shorter than the GH links, making them much less of an eyesore. This patch also replaces a few links that linked to the old bugzilla instance on llvm.org.
2025-09-03[libc++][C++03] Backport #111127, #112843 and #121620 (#155571)Nikolas Klauser2-4/+0
2025-09-01[libc++] Remove a few GCC workarounds that aren't needed anymore (#156290)Nikolas Klauser2-7/+1
2025-08-29[libc++] Disable cv-qualified arithmetic hash specializations (#155786)Nikolas Klauser3-0/+30
#140407 accidentally enabled `hash` for cv-qualified types. This patch disables these specializations again.
2025-08-25[libcxx][test] Fix typos (#155217)Stephan T. Lavavej12-42/+42
I noticed a typo in the directory name `refwrap.comparissons`, then did a quick pass to fix typos elsewhere in the tests. All fixes were manual (some carefully search-and-replaced); I used [cspell](https://www.npmjs.com/package/cspell) to find them.
2025-08-23[libc++] Add tag types to all the __tuple_impl constructors (#154517)Nikolas Klauser1-0/+27
This fixes a bug reported in https://github.com/llvm/llvm-project/pull/151654#issuecomment-3205410955.
2025-08-23[libc++] Fix ABI break introduced by switching to _LIBCPP_COMPRESSED_PAIR ↵Nikolas Klauser3-0/+12
(#154686) LLVM 20 contained an ABI break that can result in the size of `std::unordered_{map,set,multimap,multiset}` and `std::deque` changing when used with an allocator type that is empty and contains a base class that is the same across rebound allocator instantiations (e.g. ``Allocator<int>`` and ``Allocator<char>`` are both empty and contain the same base class). In addition, the layout of a user-defined type that: - contains one of the following containers: `std::unordered_{map,set,multimap,multiset}`, `std::deque`, `std::map`, `std::set`, `std::multimap`, `std::multiset`, `std::list` or `std::vector`, and - passes an empty allocator, comparator or hasher type to that container, and - has a member of that same empty allocator, comparator or hasher type inside the enclosing struct, and - that member is either marked with `[[no_unique_address]]` or optimized out via the EBO (empty base optimization) technique saw its size increase from LLVM 19 to LLVM 20. This was caused by the usage of `[[no_unique_address]]` within some of libc++'s containers in a way that allowed subtle interactions with enclosing objects. This is fixed in LLVM 21 on Clang (returning to the LLVM 19 ABI), however that implies an ABI break from LLVM 20 to LLVM 21. Furthermore, fixing this causes a slight regression to constant evaluation support in `std::unique_ptr`. Specifically, constant evaluation will now fail when the deleter relies on being value-initialized for constant-evaluation admissibility. If a default-initialized deleter can be used during constant evaluation, or if the default constructor is non-trivial, the `unique_ptr` is not affected by this regression. In particular, this regression does not impact any `unique_ptr` using the default deleter. Note that there is currently no way to realistically fix this ABI break on GCC, therefore GCC will remain on the ABI introduced in LLVM 19. That also means that Clang and GCC will have a slightly different ABI for the small subset of types listed above until we are able to apply the same fix we did with Clang on GCC. We fix this regression by surrounding the members of the `_LIBCPP_COMPRESSED_PAIR` with an anonymous struct. This restricts the shifting of empty types to the front of the `_LIBCPP_COMPRESSED_PAIR` instead of throughout the surrounding object. This "frees up" the zero offset to contain another object of the same type, restoring the ability to perform EBO or to elide the storage for a type with `[[no_unique_address]]` in the enclosing (user-defined) struct. Fixes #154146 Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-08-21[libcxx][test] Silence nodiscard warnings (#154622)Stephan T. Lavavej3-6/+6
MSVC's STL marks `std::make_shared`, `std::allocate_shared`, `std::bitset::to_ulong`, and `std::bitset::to_ullong` as `[[nodiscard]]`, which causes these libcxx tests to emit righteous warnings. They should use the traditional `(void)` cast technique to ignore the return values.
2025-08-19[libc++][tuple.apply] Implement P2255R2 make_from_tuple part. (#152867)yronglin2-0/+37
Implement P2255R2 tuple.apply part wording for `std::make_from_tuple`. ``` Mandates: If tuple_size_v<remove_reference_t<Tuple>> is 1, then reference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))> is false. ``` Fixes #154274 --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-08-18[libc++] Implement P3168R2: Give optional range support (#149441)William Tran-Viet3-0/+236
Resolves #105430 - Implement all required pieces of P3168R2 - Leverage existing `wrap_iter` and `bounded_iter` classes to implement the `optional` regular and hardened iterator type, respectively - Update documentation to match
2025-08-13[libc++] Move some standard tests from test/libcxx (#152982)Nikolas Klauser5-0/+337
This also removes some tests which were redundant, wrong, or never run. Specifically, - `libcxx/utilities/meta/stress_tests/*` were never run and are of questionable usefulness - `libcxx/utilities/template.bitset/includes.pass.cpp` is completely redundant and partially incorrect Also notably, `libcxx/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp` has been refactored to only test the standard mandate.
2025-08-11[libc++] Fix std::variant evaluating template arguments too eagerly (#151028)Nikolas Klauser1-0/+16
This has been reported in https://github.com/llvm/llvm-project/pull/116709#issuecomment-3105095648. Fixes #151328
2025-08-10[libc++] Implement LWG4222 'expected' constructor from a single value ↵yronglin1-0/+11
missing a constraint (#152676) Implement [LWG4222](https://wg21.link/LWG4222). Closes https://github.com/llvm/llvm-project/issues/148208 Signed-off-by: yronglin <yronglin777@gmail.com>
2025-08-09[clang] Improve nested name specifier AST representation (#147835)Matheus Izvekov1-2/+2
This is a major change on how we represent nested name qualifications in the AST. * The nested name specifier itself and how it's stored is changed. The prefixes for types are handled within the type hierarchy, which makes canonicalization for them super cheap, no memory allocation required. Also translating a type into nested name specifier form becomes a no-op. An identifier is stored as a DependentNameType. The nested name specifier gains a lightweight handle class, to be used instead of passing around pointers, which is similar to what is implemented for TemplateName. There is still one free bit available, and this handle can be used within a PointerUnion and PointerIntPair, which should keep bit-packing aficionados happy. * The ElaboratedType node is removed, all type nodes in which it could previously apply to can now store the elaborated keyword and name qualifier, tail allocating when present. * TagTypes can now point to the exact declaration found when producing these, as opposed to the previous situation of there only existing one TagType per entity. This increases the amount of type sugar retained, and can have several applications, for example in tracking module ownership, and other tools which care about source file origins, such as IWYU. These TagTypes are lazily allocated, in order to limit the increase in AST size. This patch offers a great performance benefit. It greatly improves compilation time for [stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for `test_on2.cpp` in that project, which is the slowest compiling test, this patch improves `-c` compilation time by about 7.2%, with the `-fsyntax-only` improvement being at ~12%. This has great results on compile-time-tracker as well: ![image](https://github.com/user-attachments/assets/700dce98-2cab-4aa8-97d1-b038c0bee831) This patch also further enables other optimziations in the future, and will reduce the performance impact of template specialization resugaring when that lands. It has some other miscelaneous drive-by fixes. About the review: Yes the patch is huge, sorry about that. Part of the reason is that I started by the nested name specifier part, before the ElaboratedType part, but that had a huge performance downside, as ElaboratedType is a big performance hog. I didn't have the steam to go back and change the patch after the fact. There is also a lot of internal API changes, and it made sense to remove ElaboratedType in one go, versus removing it from one type at a time, as that would present much more churn to the users. Also, the nested name specifier having a different API avoids missing changes related to how prefixes work now, which could make existing code compile but not work. How to review: The important changes are all in `clang/include/clang/AST` and `clang/lib/AST`, with also important changes in `clang/lib/Sema/TreeTransform.h`. The rest and bulk of the changes are mostly consequences of the changes in API. PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just for easier to rebasing. I plan to rename it back after this lands. Fixes #136624 Fixes https://github.com/llvm/llvm-project/issues/43179 Fixes https://github.com/llvm/llvm-project/issues/68670 Fixes https://github.com/llvm/llvm-project/issues/92757
2025-08-05[Clang] Add detailed notes explaining why `is_constructible` evaluates to ↵Corentin Jabot2-0/+3
false (Revert 16d5db7) (#151935) Adds explanation why `is_constructible` evaluates to false. This reapplies as-is e476f968bc8e438a0435d10934f148de570db8eb. This was reverted in 16d5db71b3c38f21aa17783a8758f947dca5883f because of a test failure in libc++. The test failure in libc++ is interesting in that, in the absence of nested diagnostics a bunch of diagnostics are emitted as error instead of notes, which we cannot silence with `-verify-ignore-unexpected`. The fix here is to prevent the diagnostics to be emitted in the first place. However this is clearly not ideal and we should make sure to deploy a better solution in the clang 22 time frame, in the lines of https://discourse.llvm.org/t/rfc-add-a-new-text-diagnostics-format-that-supports-nested-diagnostics/87641/12 Fixes #150601 --------- Co-authored-by: Shamshura Egor <164661612+egorshamshura@users.noreply.github.com>
2025-08-05[libc++] Remove SFINAE on __tuple_impl constructors (#151654)Nikolas Klauser1-1/+1
The SFINAE isn't required, since the primary `tuple` class already does the SFINAE checks. This removes a bit of code that was only used for these constraints. This also moves the `tuple_element` specialization for `tuple` to `__fwd/tuple.h` to avoid a dependency on `__tuple/sfinae_helpers.h` (which should be moved in a follow-up).
2025-08-01[libc++] Implement comparison operators for `tuple` added in C++23 (#148799)A. Jiang4-325/+710
And constrain the new `operator==` since C++26. This patch implements parts of P2165R4, P2944R3, and a possibly improved resolution of LWG3882. Currently, libstdc++ and MSVC STL constrain the new overloads in the same way. Also set feature-test macro `__cpp_lib_constrained_equality` and add related release note, as P2944R3 will completed with this patch. Fixes #136765 Fixes #136770 Fixes #105424
2025-07-30Revert "[libc++][Clang] Added explanation why is_constructible evaluated to ↵Victor Campos2-3/+0
false. Updated the diagnostics checks in libc++ tests. (#144220)" This reverts commit e476f968bc8e438a0435d10934f148de570db8eb. It has introduced a failure tracked by https://github.com/llvm/llvm-project/issues/150601 One libcxx test fail if libcxx is build with no exceptions and no RTTI: - libcxx/utilities/expected/expected.expected/value.observers.verify.cpp
2025-07-22[libc++] Enable some tests on `android` (#149899)Hristo Hristov2-2/+2
Android compiler was updated to r563880: https://github.com/llvm/llvm-project/pull/148998
2025-07-21[libc++] Remove mentions of Clang 18 in the test suite (#148862)Louis Dionne5-6/+4
Clang 19 has been the oldest supported version of Clang since the LLVM 20 release, but we had not cleaned up the test suite yet.
2025-07-20[libc++] Refactor internal index_sequence API to match the public one (#149475)Nikolas Klauser1-1/+1
The internal API is a lot more complicated than it actually needs to be. This refactors the internal API to match the features and names of the public one.
2025-07-17[libc++][Android] Reenable 2 tests for Android (#149415)Ryan Prichard2-6/+0
Now that the Android clang has been upgraded to clang-r563880 (llvm.org/pr148998), these two tests pass again.
2025-07-17[libc++] Move more tests into better places (#148419)Nikolas Klauser1-0/+32
2025-07-17[libc++] Add missing include <limits> to bitset to_ullong.pass.cpp test ↵Jonathan Wakely1-0/+1
(#149149) This was added to to_ulong.pass.cpp years ago by cf1dc8d39e2c9870468ca86f7956a65c7745fece but I don't think the other part of that commit matters here.
2025-07-16[libc++][Android] Update compiler and sysroot (#148998)Ryan Prichard2-2/+2
* Upgrade from r536225 to r563880. * Upgrade from ab/12644632 to f8b85cc5262c6e5cbc9a92c1bab2b18b32a4c63f, the current HEAD commit of https://android.googlesource.com/platform/prebuilts/ndk/+/refs/heads/mirror-goog-main-ndk The previous source of sysroots (ci.android.com), deleted its artifacts after a short period of time, and is currently out-of-date because of the aosp-main turndown. Updating the Docker image also fixes two tests.
2025-07-16[libc++] Update polymorphic_allocator to never contain a nullptr (#148423)Nikolas Klauser2-27/+28
According to `[mem.poly.allocator.ctor]` the pointer contained in `polymorphic_allocator` can never be null. The default constructor uses `get_default_resource()`, which never returns null and the constructor taking a pointer explicitly has a precondition that the pointer is non-null. This patch adds a warning and an assertion in case a user passes a null pointer to `polymorphic_allocator` as well as marking `resource()` to never return null. This also fixes some tests which contained UB. Fixes #148420
2025-07-15[libc++] Bump Xcode support (#148651)Louis Dionne4-4/+4
Libc++'s policy is to support only the latest released Xcode, which is Xcode 16.x. We did update our CI jobs to Xcode 16.x, but we forgot to update the documentation, which still mentioned Xcode 15. This patch updates the documentation and cleans up outdated mentions of apple-clang-15 in the test suite.
2025-07-15[libc++] P2944R3: Constrained comparisons - `optional` (#144249)Hristo Hristov12-0/+202
Partially implements [P2944R3](https://wg21.link/P2944R3) which adds constrained comparisons to std::optional. Closes #136767 # References [optional.relops](https://wg21.link/optional.relops) [optional.comp.with.t](https://wg21.link/optional.comp.with.t) --------- Co-authored-by: Hristo Hristov <zingam@outlook.com>
2025-07-11[libc++] XFAIL is_bounded_array.pass.cpp for Android as wellNikolas Klauser1-0/+3
The Android CI is currently using a compiler that's too old.
2025-07-10[libc++] Temporarily disable failing test for Android CI runnersNikolas Klauser1-0/+3
This test is currently failing in the Android CI, since the compiler used there is too old. Once the Clang version is updated this XFAIL should be removed again.
2025-07-08[libc++][Clang] Added explanation why is_constructible evaluated to false. ↵Shamshura Egor2-0/+3
Updated the diagnostics checks in libc++ tests. (#144220) Added explanation why a is constructible evaluated to false. Also fixed problem with ExtractTypeTraitFromExpression. In case std::is_xxx_v<> with variadic pack it tries to get template argument, but fails in expression Arg.getAsType() due to Arg.getKind() == TemplateArgument::ArgKind::Pack, but not TemplateArgument::ArgKind::Type. Reverts #144127 Fixies https://github.com/llvm/llvm-project/pull/143309#issuecomment-2970012054
2025-07-06[libc++] P2655R3 common_reference_t of reference_wrapper Should Be a ↵Hui2-22/+188
Reference Type (#141408) Fixes #105260 This patch applies the change as a DR to C++20. The rationale is that the paper is more like a bug fix. It does not introduce new features, it simply changes an existing behaviour (as a bug fix). MSVC STL DRed this paper to C++20 as well.
2025-06-29[libc++][NFC] Refactored equality comparisons tests for `pair` and ↵Hristo Hristov7-61/+35
`expected` (#145668) Refactored `std::expected` and `std::pair` tests to use the canonicalized names from `test_comparisions.h`, which are shared between tests. This was split from https://github.com/llvm/llvm-project/pull/139368 as per comment https://github.com/llvm/llvm-project/pull/139368#pullrequestreview-2916040573 Towards implementing [P2944R3: Comparisons for reference_wrapper](https://github.com/llvm/llvm-project/issues/105424) --------- Co-authored-by: Hristo Hristov <zingam@outlook.com> Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-06-27[libc++] P2944R3: Constrained comparisions - `tuple` (#145677)Hristo Hristov2-2/+26
Implements P2944R3 partially, which adds constrained comparisons `std::tuple`. The missing overloads introduced in [P2165R4](https://wg21.link/P2165R4) are not implemented. Uses [`__all`](https://github.com/llvm/llvm-project/blob/f7af33a9eb5b3876f219075023dc9c565d75849b/libcxx/include/__type_traits/conjunction.h#L45) instead of a fold expression, see comment: https://github.com/llvm/llvm-project/pull/141396#discussion_r2161166077 Relates to #136765 # References [tuple.rel](https://wg21.link//tuple.rel)
2025-06-25[libc++] P2944R3: Constrained comparisions - `variant` (#141396)Hristo Hristov2-5/+55
This is a follow-up and depends on #139368 being merged first. Implements [P2944R3](https://wg21.link/P2944R3) partially, which adds constrained comparisons to `std::variant` Closes #136769 Depends on #139368 # References [variant.relops](https://wg21.link/variant.relops)
2025-06-24[libc++] Fix bitset conversion functions and refactor constructor (#121348)Peng Liu2-50/+84
This patch addresses several implementation issues in `bitset`'s conversion functions `to_ullong` and `to_ulong`, and refactors its converting constructor `__bitset(unsigned long long __v)` to a more generic and elegant implementation.
2025-06-19[libc++][test] Don't pass ill-formed UTF-8 to MAKE_STRING_VIEW (#136403)S. B. Tam2-14/+24
2025-06-15[libc++] P2944R3: Constrained comparisons - update `reference_wrapper` ↵Hristo Hristov8-115/+30
implementation (#139368) Updates the implementation `std::reference_wrapper` - [P2944R3](https://wg21.link/P2944R3) as discussed in https://github.com/llvm/llvm-project/pull/117664#discussion_r1857826166 This PR also refactors the tests in preparation to implements the constrained comparisons for `optional`, `variant` etc. - Moves the test helpers (concepts and types) for testing constrained comparisons to `test_comparisons.h`. - Updates the `std::reference_wrapper` implementation to use the concept `__core_convertible_to<bool>` as per comments in #135759. Closes #138233 # References: - [refwrap.comparisons](https://wg21.link/refwrap.comparisons) --------- Co-authored-by: Hristo Hristov <zingam@outlook.com> Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-06-12[libc++] Fix constructing `bitset` from non-null-terminated arrays (#143691)A. Jiang1-0/+29
Unconditional evaluation of `char_traits<_CharT>::length(__str)` is problematic, because it causes UB when `__str` points to a non-null-terminated array. We should only call `length` (currently, in `basic_string_view`'s constructor) when `__n == npos` per [bitset.cons]/8. Drive-by change: Reduction of conditional compilation, given that - both `basic_string_view<_CharT>::size_type` and `basic_string<_CharT>::size_type` must be `size_t`, and thus - both `basic_string_view<_CharT>::npos` and `basic_string<_CharT>::npos` must be `size_t(-1)`. For the type sameness in the standard wording, see: - [string.view.template.general] - [basic.string.general] - [allocator.traits.types]/6 - [default.allocator.general]/1 Fixes #143684
2025-06-11[libc++] Upgrade to GCC 15 (#138293)Nikolas Klauser10-9/+26
2025-06-03[libc++] Fix padding calculation for function reference types (#142125)A. Jiang1-0/+19
#109028 caused `sizeof` to be sometimes applied to function reference types, which makes a program ill-formed. This PR handles reference types by specializations to prevent such bogus `sizeof` expression to be instantiated. Fixes #142118.
2025-06-03[libc++] Use `__reference_constructs_from_temporary` if eligible (#141916)A. Jiang1-5/+7
Currently, libc++'s `<tuple>` is using the deprecated `__reference_binds_to_temporary` intrinsic. This PR starts to use `__reference_constructs_from_temporary` if possible. It seems that `__reference_constructs_from_temporary` should be used via an internal type traits provided in `<__type_traits/reference_constructs_from_temporary.h>`. But given the old intrinsic was directly used, this PR doesn't switch to the current convention yet. P2255R2 is related. Although the paper indicated that constructors of `tuple` should be deleted in such a case. --------- Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-05-12[libc++][format] Discard contents since null-terminator in character arrays ↵A. Jiang2-14/+29
in formatting (#116571) Currently, built-in `char`/`wchar_t` arrays are assumed to be null-terminated sequence with the terminator being the last element in formatting. This doesn't conform to [format.arg]/6.9. > otherwise, if `decay_t<TD>` is `char_type*` or `const char_type*`, > initializes value with `static_cast<const char_type*>(v)`; The standard wording specifies that character arrays are decayed to pointers. When the null terminator is not the last element or there's no null terminator (the latter case is UB), libc++ currently produces different results. Also fixes and hardens `formatter<CharT[N], CharT>::format` in `<__format/formatter_string.h>`. These specializations are rarely used. Fixes #115935. Also checks the preconditions in this case, which fixes #116570.
2025-05-12[libc++] Simplify the implementation of std::get for pairs (#114984)Nikolas Klauser1-46/+91
This makes it clearer what the functions actually do. As a nice side-effect it also avoids a function call. If the C++03 header split is successful we could drop `__get_pair` entirely.
2025-05-07[libc++] Implement P3379R0 Constrain `std::expected` equality operators ↵yronglin6-36/+65
(#135759) Closes #118135 Co-authored-by: A. Jiang <de34@live.cn>
2025-04-29[libc++][pair] P2944R3: Constrain `std::pair`'s equality operator (#136672)Hristo Hristov1-0/+26
Implements https://wg21.link/P2944R3 (partially): - [pairs.spec](https://eel.is/c++draft/pairs.spec) Related issues: - Related to #105424 - Related to #118135 - PR https://github.com/llvm/llvm-project/pull/135759 - PR https://github.com/llvm/llvm-project/pull/117664 Closes: [#136763](https://github.com/llvm/llvm-project/issues/136763) # References - https://eel.is/c++draft/concept.booleantestable - https://eel.is/c++draft/concept.equalitycomparable --------- Co-authored-by: Hristo Hristov <zingam@outlook.com> Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-04-19[libc++] Properly decay functions in CTAD for `pair` (#134544)A. Jiang1-0/+60
This patch makes instantiation of `pair` in CTAD a bit lazier to avoid instantiating invalid `pair` specialization before the decaying explicit deduction guide works.
2025-04-14[libc++] Implement P2897R7 aligned_accessor: An mdspan accessor expressing ↵Damien L-G1-0/+113
pointer over-alignment (#122603) Closes #118372