Commit Graph

11229 Commits

Author SHA1 Message Date
Christopher Di Bella
64454daab0
[libcxx] reorganises the hardening documentation (#73159)
The reorganisation assists with identifying information that's relevant
to the reader by using sections, note/warning blocks, and highlighted
lists.

Some rewording was necessary to fit the new structure and some to
improve flow. Changes to the intention of the documentation have not
been made.

---------

Co-authored-by: Will Hawkins <whh8b@obs.cr>
2023-12-06 14:23:35 -08:00
Michael Kenzel
0365677692
[libc++] Remove dependence on <ciso646> (#73271)
C++23 removed `<ciso646>` from the standard library. The header is used
in a few places in order to pull in implementation-specific and feature
test macros. The new way of doing that is `<version>`, which should be
supported by all supported implementations. This change replaces all
those uses of `<ciso646>` with `<version>`.
2023-12-06 11:42:55 -05:00
Stephan T. Lavavej
3aee4a9628
[libc++] Update <source_location> and msvc_stdlib_force_include.h (#74266)
This makes libc++'s <filesystem> tests compatible with MSVC's STL.

In msvc_stdlib_force_include.h, we need to define 3 more macros:

- _CRT_DECLARE_NONSTDC_NAMES activates the POSIX names of
  `getcwd` etc. As the comment explains, we need this because
  we test with Clang `-fno-ms-compatibility`, which defines 
  `__STDC__` to `1`, which causes the UCRT headers to disable 
  the POSIX names by default.
- Then we need _CRT_NONSTDC_NO_WARNINGS to avoid emitting
  deprecation warnings about the POSIX names.
- Finally, we need `NOMINMAX` to seal away the ancient evil.

These macros are documented in https://learn.microsoft.com/en-us/cpp/c-runtime-library/compatibility?view=msvc-170.

As a drive-by change, the patch adds a "simulated" macro for 
__has_feature(hwaddress_sanitizer). It also clang-formats all
of msvc_stdlib_force_include.h and removes guards for
__has_builtin(__builtin_source_location) in <source_location>,
since those are not needed anymore.
2023-12-06 09:04:06 -05:00
Stephan T. Lavavej
bcb917eba7
[libc++][test] Fix more MSVC warnings (#74256)
Found while running libc++'s test suite with MSVC's STL.
2023-12-06 08:52:50 -05:00
Stephan T. Lavavej
02d513cf3a
[libc++][test] Drop unnecessary typename and template for layout_meow::mapping (#74571)
This is a pure syntax cleanup, I don't need it for running libc++'s
tests with MSVC's STL.

This is possible because std::layout_meow and layout_wrapping_integral<1729>
aren't dependent types. We only need typename and template when reaching
into a dependent type, like `typename OtherLayout::template mapping<E2>` or
`typename layout_wrapping_integral<Wraps>::template mapping<Extents>`.
2023-12-06 08:48:43 -05:00
Stephan T. Lavavej
bfdc562d0c
[libc++] Fix copy-paste damage in ranges::rotate_copy and its test (#74544)
Found while running libc++'s tests with MSVC's STL.

`ranges::rotate_copy` takes `forward_iterator`s as this test's comment
banner correctly depicts. However, this test had bogus assertions
expecting that `ranges::rotate_copy` would be constrained away for
not-quite-**bidi** iterators. @philnik777 confirmed that these were
copy-paste relics from the `ranges::reverse_copy` test.

I fixed this by replacing the assertions with the test types that aren't
quite **forward** iterators/ranges. Additionally, I noticed that the
top-level `test()` function was missing coverage with the weakest
possible `forward_iterator<int*>`.

This revealed that the product code in `ranges_rotate_copy.h` was
similarly damaged. In addition to fixing it by taking `forward_iterator`
and `forward_range` as depicted in the Standard, this drops the
inclusion of `<__iterator/reverse_iterator.h>` as this algorithm doesn't
need `std::__reverse_range`.
2023-12-06 02:29:09 -08:00
Tacet
02f4b36ad5
[libc++] Refactor of ASan annotation functions (#74023)
This commit refactors the ASan annotation functions in libc++ to reduce
unnecessary code duplication. Additionally it adds a small optimization.

- Eliminates two redundant function versions by utilizing the
`[[maybe_unused]]` attribute and guarding function bodies with `#ifndef
_LIBCPP_HAS_NO_ASAN`.
- Introduces an additional guard to an auxiliary function, allowing the
removal of a no-ops function body. This approach avoids relying on the
optimizer for code elimination.

Fixes #73043
2023-12-05 13:27:08 -05:00
Stephan T. Lavavej
f1db578f0d
[libc++][test] Fix assumptions that std::array iterators are pointers (#74430)
Found while running libc++'s tests with MSVC's STL, where `std::array`
iterators are never pointers.

Most of these changes are reasonably self-explanatory (the `std::array`s
are right there, and the sometimes-slightly-wrapped raw pointer types
are a short distance away). A couple of changes are less obvious:

In `libcxx/test/std/containers/from_range_helpers.h`, `wrap_input()` is
called with `Iter` types that are constructible from raw pointers. It's
also sometimes called with an `array` as the `input`, so the first
overload was implicitly assuming that `array` iterators are pointers. We
can fix this assumption by providing a dedicated overload for `array`,
just like the one for `vector` immediately below. Finally,
`from_range_helpers.h` should explicitly include both `<array>` and
`<vector>`, even though they were apparently being dragged in already.

In `libcxx/test/std/containers/views/views.span/span.cons/iterator_sentinel.pass.cpp`,
fix `throw_operator_minus`. The error was pretty complicated, caused by
the concepts machinery noticing that `value_type` and `element_type`
were inconsistent. In the template instantiation context, you can see
the critical detail that `throw_operator_minus<std::_Array_iterator>` is
being formed.

Fortunately, the fix is extremely simple. To produce `element_type`
(which retains any cv-qualification, unlike `value_type`), we shouldn't
attempt to `remove_pointer` with the iterator type `It`. Instead, we've
already obtained the `reference` type, so we can `remove_reference_t`.
(This is modern code, where we have access to the alias templates, so I
saw no reason to use the older verbose form.)
2023-12-05 11:25:42 -05:00
Louis Dionne
953ac952eb
[libc++][NFC] Use aliases instead of typedefs in std::array (#74491)
As requested in https://github.com/llvm/llvm-project/pull/74482.
2023-12-05 11:21:06 -05:00
Louis Dionne
77a00c0d54
[libc++] Replace uses of _VSTD:: by std:: (#74331)
As part of the upcoming clang-formatting of libc++, this patch performs
the long desired removal of the _VSTD macro.

See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
for the clang-format proposal.
2023-12-05 11:19:15 -05:00
Jakub Mazurkiewicz
a7993faf0c
[libc++] Mark P2017R1 as complete (#74484)
[P2017R1](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2017r1.html#wording)
appears to have been implemented in LLVM 16.0:
https://godbolt.org/z/GbcT4rjcd.
2023-12-05 17:14:35 +01:00
Stephan T. Lavavej
164c204a19
[libc++][test] Fix simple warnings (#74186)
Found while running libc++'s tests with MSVC's STL. This fixes 3 kinds of warnings:

- Add void-casts to fix `-Wunused-variable` warnings.
- Avoid sign/truncation warnings in `ConvertibleToIntegral.h`.
- Add `TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED` to avoid mixing preprocessor 
  and runtime tests.
- Cleanup: Add `TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED` for
  consistency.
2023-12-05 09:46:41 -05:00
Dominik Wójt
c27de23b27
[libc++] tests with picolibc: Fix expected error message (#74452)
Newlib's strerror function returns an empty string for unknown errnum
values as described in [1].

[1]: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/string/strerror.c;hb=HEAD
2023-12-05 09:13:01 -05:00
Louis Dionne
9eea744183
[libc++] Add a merge driver that can apply clang-format (#73712)
In preparation for the moment when we'll clang-format the whole code
base, this patch adds a script that can be used to rebase patches across
clang-format changes mechanically, without requiring manual
intervention.

See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all.
2023-12-04 15:24:37 -05:00
Louis Dionne
b18a46e35d
[libc++][NFC] Add a few clang-format annotations (#74352)
This is in preparation for clang-formatting the whole code base. These
annotations are required either to avoid clang-format bugs or because
the manually formatted code is significantly more readable than the
clang-formatted alternative. All in all, it seems like very few
annotations are required, which means that clang-format is doing a very
good job in most cases.
2023-12-04 15:17:31 -05:00
Kamau Bridgeman
503dbe75a0 XFailing test cases that fail on PowerPC
These test cases fail when the libcxx and libcxxabi runtimes are
built on Linux PowerPC. XFailing them until the issue is resolved.
2023-12-04 12:11:45 -06:00
Louis Dionne
4c19854222
[libc++] Rename _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI (#74095)
In preparation for running clang-format on the whole code base, we are
also removing mentions of the legacy _LIBCPP_INLINE_VISIBILITY macro in
favor of the newer _LIBCPP_HIDE_FROM_ABI.

We're still leaving the definition of _LIBCPP_INLINE_VISIBILITY to avoid
creating needless breakage in case some older patches are checked-in
with mentions of the old macro. After we branch for LLVM 18, we can do
another pass to clean up remaining uses of the macro that might have
gotten introduced by mistake (if any) and remove the macro itself at the
same time. This is just a minor convenience to smooth out the transition
as much as possible.

See
https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
for the clang-format proposal.
2023-12-04 10:25:14 -05:00
Dominik Wójt
9f78edbd20
[libc++] tests with picolibc: Fix iterator diff_type to std::streamoff (#74072)
The hardcoded value of long int was not valid for newlib and picolibc.
2023-12-03 16:38:38 +01:00
Stephan T. Lavavej
c000f754bf
[libc++][test] Avoid non-Standard zero-length arrays (#74183)
Found while running libc++'s test suite with MSVC's STL, where we use
both MSVC's compiler and Clang/LLVM.

MSVC's compiler rejects the non-Standard extension of zero-length
arrays. For conformance, I'm changing these occurrences to
`std::array<int, 0>`.

Many of these files already had `#include <array>`; I'm adding it to the
rest.

I wanted to add `-Wzero-length-array` to
`libcxx/utils/libcxx/test/params.py` to prevent future occurrences, but
it complained about product code 😿 :

```
In file included from /home/runner/_work/llvm-project/llvm-project/libcxx/test/std/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp:18:
In file included from /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/istream:170:
In file included from /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/ostream:172:
In file included from /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__system_error/error_code.h:18:
In file included from /home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__system_error/error_category.h:15:
/home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/string:811:25: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
  811 |         char __padding_[sizeof(value_type) - 1];
      |                         ^~~~~~~~~~~~~~~~~~~~~~
/home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/string:817:19: note: in instantiation of member class 'std::basic_string<char>::__short' requested here
  817 |     static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
      |                   ^
/home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/string:2069:5: note: in instantiation of template class 'std::basic_string<char>' requested here
 2069 |     _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
      |     ^
/home/runner/_work/llvm-project/llvm-project/build/generic-cxx03/include/c++/v1/__string/extern_template_lists.h:31:60: note: expanded from macro '_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST'
   31 |   _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \
      |                                                            ^
```

I pushed a tiny commit to fix unrelated comment typos, in an attempt to
clear out spurious CI failures.
2023-12-03 10:47:09 +01:00
Eric
f376a3bba1
Work around GCC test failure that is caused by enabling optimizations. (#73998)
While trying to work around MSAN/TSAN build timeouts, we enabled
optimizations on some tests. This caused GCC to start complaining that
some values may be uninitialized. I believe GCC is wrong, but more
investigation is needed.

The values are initialized when the variable `__g` is either < 0 or >=
0. Which only leaves out NaN I believe, which is likely well into UB
   land anyway.

However, more investigation needed.
2023-12-03 00:43:41 -05:00
Stephan T. Lavavej
8f018d3ca0
[libc++][test] Make the feature-test macro tests more portable (#74185)
Found while running libc++'s test suite with MSVC's STL.

This is a followup to @philnik777's recent #71002 (thank you!) which
provided the existing examples of `__cpp_lib_barrier` and
`__cpp_lib_polymorphic_allocator`:

66a3e4fafb/libcxx/utils/generate_feature_test_macro_components.py (L199-L203)

66a3e4fafb/libcxx/utils/generate_feature_test_macro_components.py (L866-L870)

Applying that new pattern to the feature-test macros here gets their
corresponding tests passing for us.

🤖 Only `generate_feature_test_macro_components.py` was manually
updated; the other files were regenerated.
2023-12-02 17:41:23 -08:00
Stephan T. Lavavej
091a9f4957
[libc++][test] Avoid truncation warnings from double to float (#74184)
Found while running libc++'s test suite with MSVC's STL, where we use
both MSVC's compiler and Clang/LLVM.

MSVC really enjoys emitting "warning C4305: 'initializing': truncation
from 'double' to 'float'". It might look repetitive, but `T(value)`
avoids this warning. (According to my understanding, the compiler looks
at the immediate context, and if it's a functional-style cast, it's
satisfied that the truncation was intentional. Not even the
direct-initialization context of `T unexpected(-9999.99)` is enough to
activate that "ok, the programmer knows what they're getting" codepath.)

I usually prefer to use `static_cast` instead of functional-style casts,
but I chose to remain consistent with the surrounding code.

By the way, you might notice that `1.5` doesn't need these changes. This
is because it's exactly representable as both a `double` and a `float`.
Values like `3.125` instead of `3.1` would similarly avoid truncation
warnings without the need for casts, but I didn't want to intrusively
change the test code.
2023-12-02 17:40:41 -08:00
Hui
36dd743212
[libc++][test] add more benchmarks for stop_token (#69590) 2023-12-02 16:14:38 +00:00
Nikolas Klauser
0e823b02ba [libc++] Update libcpp-uglify-attributes to diagnose all attributes in C++03 2023-12-02 14:04:01 +01:00
Haowei
1f8f9e3163
[libc++] Correct libcxx default linker script behavior (#74130)
Patch 4b1fe097f9 introduced a bug when
building libc++ for Fuchsia, it disabled the libc++.so linker script by
default. This patch restores its original behavior.
2023-12-01 15:37:04 -05:00
eric
1a013b61dc Allow libc++ image tag to be specified via enviroment variables.
This change is needed for changes I'm working on that allow
github workflows to build, push, and otherwise manage the container
images they use
2023-12-01 14:34:36 -05:00
Louis Dionne
f19571ee78 [libc++] Revert "Compile MSAN/TSAN failing test with -O1 (#73555)"
This reverts commit 61aef978d6, which
broke the CI on GCC.
2023-12-01 09:02:16 -05:00
Nikolas Klauser
1ee41b4153 [libc++][NFC] Update the remaining old license headers 2023-12-01 11:29:43 +01:00
Stephan T. Lavavej
4e2216e184
[libc++][test] ADDITIONAL_COMPILE_FLAGS should be a space-separated list (#73541)
Found while running libc++'s test suite with MSVC's STL.

`ADDITIONAL_COMPILE_FLAGS` is a `ParserKind.LIST`:

3c23ed156f/libcxx/utils/libcxx/test/format.py (L104-L108)

With a comma-separated example:

3c23ed156f/libcxx/utils/libcxx/test/format.py (L223-L228)

And comma-separated test coverage:

dd3184c30f/libcxx/test/libcxx/selftest/additional_compile_flags/substitutes-in-run.sh.cpp (L12-L15)

Because the machinery splits on commas:

dd09221a29/llvm/utils/lit/lit/TestRunner.py (L1882-L1883)

dd09221a29/llvm/utils/lit/lit/TestRunner.py (L1951-L1956)

However, most (although not all) usage of `ADDITIONAL_COMPILE_FLAGS` is
treating it as space-separated. That apparently works in the normal
Clang environment, but in my exotic configuration it causes `"-DMEOW
-DWOOF"` to be passed as a single argument to MSVC, which then emits
"warning C5102: ignoring invalid command-line macro definition
`'_LIBCPP_DISABLE_DEPRECATION_WARNINGS
-D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT'`", causing test failures due to
warnings-as-errors.

This PR changes `ADDITIONAL_COMPILE_FLAGS` to actually be parsed as a
space-separated list, and changes the few uses/examples that had commas.
2023-11-30 13:54:52 -08:00
Dominik Wójt
4c338f80c4
[libc++] picolibc: avoid warning in __locale (#73937) 2023-11-30 09:32:06 -05:00
Hui
6677f029b2
[libc++] Workaround linker errors in floating-point atomic tests (#73398)
We now add -latomic whenever we detect that it's supported on the platform,
and we mark the tests as UNSUPPORTED on platforms where non-lockfree
atomics are not supported.
2023-11-30 09:18:30 -05:00
Mark de Wever
efc60dc007
[libc++] Reenable codecvt in the dylib. (#73679)
The header is used in the dylib, this is not an issue at the moment
since the dylib is built using C++23 but it would be when building
with C++26.

Post release comments in #72496 seem to indicate this removal is an
issue for Fuchsia.
2023-11-29 18:02:10 -05:00
Eric
61aef978d6
Compile MSAN/TSAN failing test with -O1 (#73555)
This attempts to fix flakes on the bots where the modified test times
out while running under sanitizers.

Turning on the optimizer for just this test appears to mostly fix the
issue.
2023-11-29 18:01:18 -05:00
Eric
9ac64abc02
[libc++] Remove linux Buildkite builders entirely (#73825)
This removes the Google hosted Linux buildkite builders. We have since
moved all of them over to github actions.

Follow up changes will be sent for android.
2023-11-29 17:34:45 -05:00
Michael Platings
be811d1617 [libc++] Run picolibc tests with qemu
This patch actually runs the tests for picolibc behind an emulator,
removing a few workarounds and increasing coverage.

Differential Revision: https://reviews.llvm.org/D155521
2023-11-29 17:21:08 -05:00
Mark de Wever
16b8c9608f
[libc++][format] Fixes formatting code units as integers. (#73396)
This paper was voted in as a DR, so it's retroactively enabled back to
C++20; the C++ version that introduced std::format.

Implements:
- P2909R4 Fix formatting of code units as integers (Dude, where’s my
``char``?)
2023-11-29 17:55:09 +01:00
Michael Platings
8aeacebf28 [libc++] Add initial support for picolibc
Picolibc is a C Standard Library that is commonly used in embedded
environments. This patch adds initial support for this configuration
along with pre-commit CI. As of this patch, the test suite only builds
the tests and nothing is run. A follow-up patch will make the test suite
actually run the tests.

Differential Revision: https://reviews.llvm.org/D154246
2023-11-29 10:43:16 -05:00
Louis Dionne
1a5af34e6f
[libc++] Speed up classic locale (take 2) (#73533)
Locale objects use atomic reference counting, which may be very
expensive in parallel applications. The classic locale is used by
default by all streams and can be very contended. But it's never
destroyed, so the reference counting is also completely pointless on the
classic locale. Currently ~70% of time in the parallel stringstream
benchmarks is spent in locale ctor/dtor. And the execution radically
slows down with more threads.

Avoid reference counting on the classic locale. With this change
parallel benchmarks start to scale with threads.

This is a re-application of f8afc53d64 (aka PR #72112) which was
reverted in 4e0c48b907 because it broke the sanitizer builds due
to an initialization order fiasco. This issue has now been fixed by
ensuring that the locale is constinit'ed.

Co-authored-by: Dmitry Vyukov <dvyukov@google.com>
2023-11-29 09:31:05 -05:00
Louis Dionne
fa712b0764
[libc++] Build the dylib with sanitizers when requested (#73656)
We were detecting which sanitizer flags to use when building
libc++.dylib but we were never actually adding those flags to the
targets, which means that our sanitized builds would basically build the
dylib without any sanitizers enabled.
2023-11-29 09:29:44 -05:00
Stephan T. Lavavej
0d3c40b82b
[libc++] Remove unused Python imports (#73724)
VSCode's Pylance extension informed me, and text searching confirmed,
that these imports are unused. I believe we should be able to remove
them harmlessly.
2023-11-29 09:25:06 -05:00
Louis Dionne
ac8c9f1e39
[libc++] Properly guard std::filesystem with >= C++17 (#72701)
<filesystem> is a C++17 addition. In C++11 and C++14 modes, we actually
have all the code for <filesystem> but it is hidden behind a non-inline
namespace __fs so it is not accessible. Instead of doing this unusual
dance, just guard the code for filesystem behind a classic C++17 check
like we normally do.
2023-11-28 18:41:59 -05:00
Stephan T. Lavavej
ab562686d1
[libc++][test] Change forbidden extents<char> to extents<signed char> (#73535)
Found while running libc++'s test suite with MSVC's STL.

[mdspan.extents.overview]/1.1 mandates that IndexType is a signed or
unsigned integer type, which excludes char.

MSVC's STL enforces the Mandates here, so this PR changes the relevant
occurrences of `char to `signed char`. To make this work, we also need
to add an `operator signed char()` to the test helper type `IntType` so
it remains unambiguously convertible, and then we can remove `operator
char()`.

libc++ should also enforce the Mandates, but this PR doesn't attempt to make
such a change.
2023-11-28 18:20:40 -05:00
Nikolas Klauser
ed27a4edb0
[libc++][PSTL] Implement std::equal (#72448)
Differential Revision: https://reviews.llvm.org/D157131

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-11-28 16:02:18 -05:00
James Y Knight
e1f59ad9f6
Mark some std::string functions noinline. (#72869)
The intent of these particular functions, since their introduction, was
to NOT be inlinable.

However, the mechanism by which this was accomplished was non-obvious,
and stopped working when string is compiled for C++20.

A longstanding behavior specified by the C++ standard is that
instantiation of the body of a template function is suppressed by an
extern template declaration -- unless the function is explicitly marked
either constexpr or inline. Of course, if the body is not instantiated,
then it cannot possibly be inlined, and thus all the functions listed in
libcxx/include/__string/extern_template_lists.h were uninlineable.

But, in C++20 mode, string functions were annotated constexpr, which
means they _are_ instantiated, and do become inlineable. And, in fact,
they do get inlined, which has caused noticeable binary-size growth for
users.

For example, in C++17,
`std::string f(std::string *in) { return *in; }`
does not inline the copy-constructor call, and instead generates a call
to the exported function defined in the libc++ shared library.

I think we probably don't want to mark all functions that are currently
in the extern template list as noinline, as many of them really are
reasonable inlining candidates. Thus, I've restricted this change to
only the few functions that were clearly intended to be outlined.

See commits like b019c5c037 (and some
others like it) for background, in which functions were removed from the
extern template list in the unstable ABI in order to allow the
short-string case to be inlined, while moving the long-string case to a
separate function, added to the extern template list.
2023-11-28 15:57:00 -05:00
Mark de Wever
efac016e32
[NFC][libc++] Refactors the time.cal tests. (#73356)
These tests use an old way to test code in constexpr context. This
changes the code to the idomatic libc++ method.

This is a preparation for #73162.

Side changes
- Updated formatting
- Made some helper functions constexpr
- Some naming improvements
2023-11-28 19:19:21 +01:00
Stephan T. Lavavej
a3529aa92e
[libc++][test] Avoid preprocessor directives in macro argument lists (#73440)
Found while running libc++'s test suite with MSVC's STL.

MSVC has a level 1 "warning C5101: use of preprocessor directive in
function-like macro argument list is undefined behavior". I don't know
why Clang doesn't complain about this.

There are some formatting tests which densely interleave preprocessor
directives within function-like macros, and they would need invasive
changes. For now, I'm just skipping those tests.

However, a few tests were only slightly affected, and I was able to add
a new test macro `TEST_IF_AIX` to make them portable.
2023-11-27 17:37:59 -08:00
Stephan T. Lavavej
7cbf9598cc
[libc++][test] Avoid using allocator<const T> (#73545)
Found while running libc++'s test suite with MSVC's STL.

MSVC's STL rejects `allocator<const T>`. This may or may not be
justified by the current Standardese (it was bogus in the C++03 era),
but it's how we reject usage like `vector<const T>`.

A bunch of `mdspan` tests are failing for us because some centralized
machinery is using `allocator<const T>`. Testing that `mdspan` and its
associated types work properly with `const T` is good and necessary, but
directly allocating `const T` is what's a problem for MSVC's STL. I'd
like to ask for a very targeted change here that preserves all of the
test coverage but changes how `ElementPool` interacts with `allocator`.

This intentionally leaves `ElementPool::get_ptr()` returning `T*`
(pointer-to-possibly-const), so there's no externally visible
difference.
2023-11-27 17:19:34 -08:00
Louis Dionne
e666e27485
[libc++] Move compiler-detection Lit features first (#73544)
Lit features are evaluated in order. Some checks may require the
compiler detection to have run first in order to work properly, for
example some checks being added in https://reviews.llvm.org/D154246
which require GCC to have been detected. It is kind of brittle to rely
on such ordering, but in practice moving the compiler detection first
should never hurt.
2023-11-27 15:53:35 -05:00
Kirill Stoimenov
4e0c48b907 Revert "[libc++] Speed up classic locale (#72112)"
Looks like it broke the ASAN build: https://lab.llvm.org/buildbot/#/builders/168/builds/17053/steps/9/logs/stdio

This reverts commit f8afc53d64.
2023-11-27 20:21:58 +00:00
Louis Dionne
2b7cca1ccf [libc++] Add missing REQUIRES for exception handling test
It otherwise fails on Windows.
2023-11-27 15:04:04 -05:00