Commit Graph

13287 Commits

Author SHA1 Message Date
Dan Katz
2a631b61e3 Separate parameter/variable reflections. 2025-06-19 19:17:03 +03:00
Dan Katz
bebe293731 No mixing annotations and attributes. 2025-06-19 10:02:34 +03:00
Barry Revzin
a2548ff890 Fixing alignment_of references members (#153) 2025-06-13 07:52:18 -04:00
Dan Katz
3e871e8698 naming -> designating 2025-06-12 12:13:29 -04:00
Dan Katz
84be714bf8 Merge branch 'main' into wip 2025-06-11 14:35:33 -04:00
Dan Katz
b5a6e6d1f2 Merge branch 'p2996' into wip 2025-06-11 11:16:43 -04:00
Nikolas Klauser
b10d711362 [libc++][NFC] Move __libcpp_is_integral into the else branch (#142556)
This makes it clear that `__libcpp_is_integral` is an implementation
detail of `is_integral` if we don't have `__is_integral` and not its own
utility.
2025-06-11 14:33:41 +02:00
Nikolas Klauser
3c56437eaf [libc++] Refactor signed/unsigned integer traits (#142750)
This patch does a few things:
- `__libcpp_is_signed_integer` and `__libcpp_is_unsigned_integer` are
refactored to be variable templates instead of class templates.
- the two traits are merged into a single header
`<__type_traits/integer_traits.h>`.
- `__libcpp_signed_integer`, `__libcpp_unsigned_integer` and
`__libcpp_integer` are moved into the same header.
- The above mentioned concepts are renamed to `__signed_integer`,
`__unsigned_integer` and `__signed_or_unsigned_integer` respectively.
2025-06-11 14:31:13 +02:00
Nikolas Klauser
b49c7896c0 [libc++] Fix constraints in __countr_zero and __popcount
Currently these two functions are constrained on `is_unsigned`, which is
more permissive than what is required by the standard for their public
counterparts. This fixes the constraints to match the public functions
by using `__libcpp_is_unsigned_integer` instead.
2025-06-11 14:29:52 +02:00
maflcko
a17e97e677 [libc++] Add missing C++20 [time.point.arithmetic] (#143165)
This was part of https://wg21.link/p0355r7, but apparently never
implemented.

---------

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-authored-by: Hristo Hristov <zingam@outlook.com>
2025-06-11 08:43:23 +02:00
Louis Dionne
616f83530f [libc++] Move swap test to a .compile.pass.cpp (#143167) 2025-06-10 15:22:42 -04:00
Louis Dionne
baceb7923f [libc++] Don't skip localization-related headers in header tests (#134877)
When localization is disabled, we used to skip testing a lot of headers.
However, these headers are now "no-ops" when localization is disabled,
so they can actually be included. As such, we should test their
inclusion in our usual header inclusion tests.
2025-06-10 14:12:46 -04:00
Dan Katz
5b709111a9 Account for out-of-line declarations in members_of. 2025-06-10 10:35:24 -04:00
Nikolas Klauser
f2fede6095 [libc++] Document our ABI guarantees and what ABI flags exist to modify these guarantees (#132615) 2025-06-10 12:59:08 +02:00
Nikolas Klauser
eccd81f20b [libc++] Simplify the implementation of std::hash (#140407)
Instead of providing full specializations of `hash` for every arithmetic
type, this moves the implementation to a base class, which is
specialized via `enable_if`s instead.
2025-06-10 06:32:56 +02:00
Nikolas Klauser
040e9e02cc [libc++] Inline __has_feature and __has_extension uses (#133634)
Since GCC now supports `__has_feature` and `__has_extension` as well,
there isn't much of a reason to define new macros to test for the
features.
2025-06-10 05:54:15 +02:00
Louis Dionne
4d50b405f1 [libc++] Remap headers in the debug info when building the library (#143004)
The libc++ build includes a step where headers are generated. This is
required in order to preprocess some files such as the assertion handler
and the __config_site header. As a result, the library is built against
headers located inside the build directory, and the path to those
headers is what's included in the debug information of the library.

However, these headers in the build directory are usually not
persistent, which means that the debug information might end up
referring to headers that don't exist anymore. To solve this problem,
this patch uses the -fdebug-prefix-map flag supported by Clang and GCC
to remap the generated headers to the original headers in the source
directory. This provides the illusion that the library was truly built
against the in-source version of the headers.
2025-06-09 16:52:29 -04:00
Alex Guteniev
8631cddd69 libc++ test: update MinSequenceContainer.h to make some tests pass on MSVC STL (#140287)
Per [sequence.reqmts] there are these member functions.

I did not audit if any other member functions are missing. Adding these
is enough for MSVC STL
2025-06-09 18:35:27 +08:00
Dan Katz
59f41178cb Fix reflect_constant bug. 2025-06-08 18:52:44 -04:00
Aiden Grossman
20a6b63f1b [libcxx] Include __fwd/span.h in <mdspan>
This patch includes __fwd/span.h in <mdspan> so that we get the
declaration of dynamic_extent inside <mdspan>. We also clean up quite a
few tests that were manually included <span> for dynamic_extent.

This is based on feedback from #142693.

Reviewers: philnik777, ldionne

Reviewed By: philnik777

Pull Request: https://github.com/llvm/llvm-project/pull/142925
2025-06-08 21:58:36 +00:00
Hui
692c5cdb56 [libc++] Do not call reserve in flat containers if underlying container is user defined (#140379)
This is brought up in the LWG reflector. We currently call `reserve` if
the underlying container has one. But the spec does not specify what
`reserve` should do for Sequence Container. So in theory if the
underlying container is user defined type and it can have a function
called `reserve` which does something completely different.

The fix is to just call `reserve` for STL containers if it has one
2025-06-07 08:47:46 +01:00
Hui
155fd97a66 [libc++] flat_meow transparent comparator string literals (#133654)
See discussion in https://cplusplus.github.io/LWG/issue4239

    std::flat_map<std::string, int, std::less<>> m;
    m.try_emplace("abc", 5);  // hard error

The reason is that we specify in 23.6.8.7 [flat.map.modifiers]/p21
the effect to be as if `ranges::upper_bound` is called.

`ranges::upper_bound` requires indirect_strict_weak_order, which
requires the comparator to be invocable for all combinations. In this
case, it requires

    const char (&)[4] < const char (&)[4]

to be well-formed, which is no longer the case in C++26 after
https://wg21.link/P2865R6.

This patch uses `std::upper_bound` instead.
2025-06-06 13:05:36 -04:00
Nikolas Klauser
a925e90ec2 [libc++][NFC] Remove some unused code from <map> (#142408) 2025-06-06 15:27:05 +02:00
Nikolas Klauser
1d68abccb5 [libc++] Move _ITER_TRAITS and _ITER_CONCEPT into <__iterator/concepts.h> (#140528)
`_ITER_TRAITS` and `_ITER_CONCEPT` are really implenentation details of
`<__iterator/concetps.h>`, so it makes more sense to put them there than
into `<__iterator/iterator_traits.h>`.
2025-06-06 08:33:15 +02:00
Louis Dionne
9dc5dac52d [libc++] Avoid spuriously unsupporting the new FTM tests (#142024)
The new FTM tests contain text that they validate against to check the
output of the FTM generation script. However, that text lexically
contains the characters `// UNSUPPORTED: <...>`, which leads Lit to make
the whole test unsupported under these conditions. To prevent that from
happening, an `# END.` block can be used to prevent Lit from looking
further into the file for directives.
2025-06-05 13:29:57 -04:00
Aiden Grossman
5990624383 [libcxx] Add span includes to some mdspan tests (#142693)
This patch adds missing <span> includes for std::mdspan tests that use
std::span. There are other cases where we need dynamic_extent that are
handled in #142925.

This was found by running the test suite in the bootstrapping build
with Clang modules enabled.
2025-06-05 13:22:43 -04:00
A. Jiang
479f992291 [libc++] Fix basic_string::shrink_to_fit for constant evaluation (#142712)
Currently, when the string shrink into the SSO buffer, the `__rep_.__s`
member isn't activated before the `traits_type::copy` call
yet, so internal `__builtin_memmove` call writing to the buffer causes
constant evaluation failure. The existing test coverage seems a bit
defective and doesn't cover this case - `shrink_to_fit` is called on the
copy of string after erasure, not the original string object.

This PR reorders the `__set_short_size` call, which starts the lifetime
of the SSO buffer, before the copy operation. Test coverage is achieved
by calling `shrink_to_fit` on the original erased string.
2025-06-05 07:23:49 +08:00
Dan Katz
b70a36652d Fix a few bugs.
- Use canonical decl for underlying_entity_of on entity proxies
- Skip non-canonical decls for namespace members_of
2025-06-04 14:11:41 -04:00
Peng Liu
ec5610c4a2 [libc++] Ensure strong exception guarantee for forward_list::resize (#131025)
The current implementation of `forward_list::resize` does not meet the
strong exception safety guarantee required by [forward.list.modifiers]:

    If an exception is thrown by any of these member functions there is no
    effect on the container.

This patch refactors `resize()` to provide strong exception safety and
introduces additional tests to validate the strong exception guarantees
for other `forward_list` modifiers.

Fixes #118366.
2025-06-04 13:04:19 -04:00
A. Jiang
fdb11c1be6 [libc++] Disallow specializing common_reference (#141465)
`common_reference` isn't an exception for [meta.rqmts]/4, so it's better
to disallow users to specialize it.

`indirectly_readable.compile.pass.cpp` was a bit problematic. It
attempted to opt-out common reference type in some wrong ways. Also, the
standard effectively forbids opting-out common reference type for `T&`
and `T&&`. This patch removes and adjusts some problematic cases.

---------

Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-06-04 20:41:58 +08:00
Peng Liu
3e5fd77d32 [libc++] constexpr priority_queue (#140634)
This patch makes `priority_queue` constexpr as part of P3372R3.

Fixes #128671.
2025-06-04 19:58:25 +08:00
Dan Katz
5b2c490baa Fix that weird thing Barry found. 2025-06-03 15:36:30 -04:00
Louis Dionne
d0fb83531b [libc++] Remove invalid char_traits instantiations from a test (#142016)
We had a test which created invalid char_traits instantiations for
non-character types. This patch removes them.
2025-06-03 11:58:42 -04:00
A. Jiang
769c42f4a5 [libc++] Fix padding calculation for function reference types (#142125)
#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 11:54:49 -04:00
A. Jiang
437ad06f76 [libc++] Use __reference_constructs_from_temporary if eligible (#141916)
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-06-03 10:34:45 +08:00
Nikolas Klauser
705eedd47d [libc++] Remove availability annotations which can't fire anymore (#140049)
According to https://developer.apple.com/support/xcode/ the removed
annotations can't fire anymore, since the targets they would fire for
aren't supported anymore.
2025-06-02 13:13:57 -04:00
Tomohiro Kashiwada
11c3e65e1d [libc++] Remove unused include caused by wrong __has_include (#141328)
The parameter passed to __has_include has to be quoted by `<>` or `"`,
not both.
2025-06-02 13:12:40 -04:00
Dan Katz
7729ff85f9 Disable delayed access checking during 'is_accessible'.
Fixes #148.
2025-06-02 10:12:17 -04:00
Dan Katz
8013a76182 Force instantiation of Decls used as substitute arguments.
Fixes #147.
2025-06-01 10:17:50 -04:00
Jessica Clarke
35757d67ba Revert "[libc++] Re-enable std::pair trivial copy constructor for FreeBSD >= 14" (#142204)
The ABI bump to adopt the conforming ABI v1 std::pair implementation did
not end up happening for FreeBSD 14, and instead this diff was reverted
downstream in FreeBSD[1]. Align the upstream ABI config with FreeBSD's
actual ABI.

[1] ce4f1f49e036 ("Revert commit 6255157d24 from llvm-project (by
Dimitry Andric):")

This reverts commit 6255157d24.
2025-05-31 08:07:15 +01:00
Dan Katz
312f240526 Fix bug in destructurable expansion statements.
I didn't entirely figure out what's going on here, but probably this
will be improved when clang implements constexpr structured bindings.
For now, just reach into the initializer of the holding variable and use
that.

Fixes #109 and #144.
2025-05-30 16:06:10 -04:00
Hui
665148d5e1 [libc++][test] Fix test not relying on MinSequenceContainer (#140372)
The affected tests are relying on the fact that `MinSequenceContainer`
does not have `insert_range`. This prevents landing of #140287.

This PR creates a new helper class to allow the change in MinSequenceContainer.
2025-05-30 13:12:48 -04:00
Dan Katz
9b5188a261 Handle decl-type TemplateArguments in define_aggregate.
Fixes #145.
2025-05-30 08:56:09 -04:00
Ksar
b71255705b [libc++] P2165R4: Update deduction guides for map containers and container adaptors (#136011)
Fixes #135351

This PR update CATD guides to associative containers (`std::map`,
`std::multimap`, `std::unordered_map`, `std::unordered_multimap`,
`std::flat_map`, `std::flat_multimap`).

- Updated template alias for deduction guides for the relevant
associative containers.
- Added a new test to verify the deduction guides with `std::map`,
`std::multimap`, `std::unordered_map`, `std::unordered_multimap`,
`std::flat_map`, `std::flat_multimap`.
2025-05-30 15:17:06 +08:00
Dan Katz
5a8802ca2f Fix constant_of on annotations. Fixes #143. 2025-05-29 18:03:34 -04:00
Peng Liu
4ad230bebd [libc++] Refactor bitset::{any, all} (#128445)
This patch refactors the `all()` and `any()` methods in `bitset` to
eliminate redundant code while preserving the performance. Code
generation remains unchanged, as verified on Compiler
Explorer: https://godbolt.org/z/xx8hb4sPM.
2025-05-28 12:10:46 -04:00
Peng Liu
4608df5b9f [libc++] Simplify __bitset::__init (#121357)
This PR simplifies `__bitset::__init` into a more compact and readable
form, which avoids redundant computations of a `size_t` value and
eliminates the overhead of a local array.
2025-05-28 12:09:50 -04:00
James Y Knight
c3656afdf1 Revert "[libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (#131156)" (#141756)
This reverts commit c861fe8a71.

Unfortunately, this use of hidden visibility attributes causes
user-defined specializations of standard-library types to also be marked
hidden by default, which is incorrect. See discussion thread on #131156.

...and also reverts the follow-up commits:

Revert "[libc++] Add explicit ABI annotations to functions from the block runtime declared in <__functional/function.h> (#140592)"
This reverts commit 3e4c9dc299.

Revert "[libc++] Make ABI annotations explicit for windows-specific code (#140507)"
This reverts commit f73287e623.

Revert "[libc++][NFC] Replace a few "namespace std" with the correct macro (#140510)"
This reverts commit 1d411f27c7.
2025-05-28 12:04:51 -04:00
Louis Dionne
7f78ebf248 Revert "[libc++] Fix build failure with libdispatch backend (#141606)"
It turns out that we're about to revert the patches that added these
annotations in the first place. I was too hasty to land this.

This reverts commit 56594710c7.
2025-05-28 10:21:36 -04:00
Louis Dionne
56594710c7 [libc++] Fix build failure with libdispatch backend (#141606)
We get an error "cannot add 'abi_tag' attribute in a redeclaration"
because functions like `__dispatch_apply` are first declared without an
ABI tag due to `_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS` inside the
header, and then redeclared with an ABI tag in the .cpp file.
2025-05-28 10:20:48 -04:00