diff options
Diffstat (limited to 'libcxx/test')
6 files changed, 152 insertions, 50 deletions
diff --git a/libcxx/test/benchmarks/exception_ptr.bench.cpp b/libcxx/test/benchmarks/exception_ptr.bench.cpp index 7791c51..8ec7488 100644 --- a/libcxx/test/benchmarks/exception_ptr.bench.cpp +++ b/libcxx/test/benchmarks/exception_ptr.bench.cpp @@ -18,4 +18,116 @@ void bm_make_exception_ptr(benchmark::State& state) { } BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8); +void bm_exception_ptr_copy_ctor_nonnull(benchmark::State& state) { + std::exception_ptr excptr = std::make_exception_ptr(42); + for (auto _ : state) { + benchmark::DoNotOptimize(std::exception_ptr(excptr)); + } +} +BENCHMARK(bm_exception_ptr_copy_ctor_nonnull); + +void bm_exception_ptr_copy_ctor_null(benchmark::State& state) { + std::exception_ptr excptr = nullptr; + for (auto _ : state) { + std::exception_ptr excptr_copy(excptr); + // The compiler should be able to constant-fold the comparison + benchmark::DoNotOptimize(excptr_copy == nullptr); + benchmark::DoNotOptimize(excptr_copy); + } +} +BENCHMARK(bm_exception_ptr_copy_ctor_null); + +void bm_exception_ptr_move_ctor_nonnull(benchmark::State& state) { + std::exception_ptr excptr = std::make_exception_ptr(42); + for (auto _ : state) { + // Need to copy, such that the `excptr` is not moved from and + // empty after the first loop iteration. + std::exception_ptr excptr_copy(excptr); + benchmark::DoNotOptimize(std::exception_ptr(std::move(excptr_copy))); + } +} +BENCHMARK(bm_exception_ptr_move_ctor_nonnull); + +void bm_exception_ptr_move_ctor_null(benchmark::State& state) { + std::exception_ptr excptr = nullptr; + for (auto _ : state) { + std::exception_ptr new_excptr(std::move(excptr)); + // The compiler should be able to constant-fold the comparison + benchmark::DoNotOptimize(new_excptr == nullptr); + benchmark::DoNotOptimize(new_excptr); + } +} +BENCHMARK(bm_exception_ptr_move_ctor_null); + +void bm_exception_ptr_copy_assign_nonnull(benchmark::State& state) { + std::exception_ptr excptr = std::make_exception_ptr(42); + for (auto _ : state) { + std::exception_ptr new_excptr; + new_excptr = excptr; + benchmark::DoNotOptimize(new_excptr); + } +} +BENCHMARK(bm_exception_ptr_copy_assign_nonnull); + +void bm_exception_ptr_copy_assign_null(benchmark::State& state) { + std::exception_ptr excptr = nullptr; + for (auto _ : state) { + std::exception_ptr new_excptr; + new_excptr = excptr; + // The compiler should be able to constant-fold the comparison + benchmark::DoNotOptimize(new_excptr == nullptr); + benchmark::DoNotOptimize(new_excptr); + } +} +BENCHMARK(bm_exception_ptr_copy_assign_null); + +void bm_exception_ptr_move_assign_nonnull(benchmark::State& state) { + std::exception_ptr excptr = std::make_exception_ptr(42); + for (auto _ : state) { + // Need to copy, such that the `excptr` is not moved from and + // empty after the first loop iteration. + std::exception_ptr excptr_copy(excptr); + std::exception_ptr new_excptr; + new_excptr = std::move(excptr_copy); + benchmark::DoNotOptimize(new_excptr); + } +} +BENCHMARK(bm_exception_ptr_move_assign_nonnull); + +void bm_exception_ptr_move_assign_null(benchmark::State& state) { + std::exception_ptr excptr = nullptr; + for (auto _ : state) { + std::exception_ptr new_excptr; + new_excptr = std::move(excptr); + // The compiler should be able to constant-fold the comparison + benchmark::DoNotOptimize(new_excptr == nullptr); + benchmark::DoNotOptimize(new_excptr); + } +} +BENCHMARK(bm_exception_ptr_move_assign_null); + +void bm_exception_ptr_swap_nonnull(benchmark::State& state) { + std::exception_ptr excptr1 = std::make_exception_ptr(41); + std::exception_ptr excptr2 = std::make_exception_ptr(42); + for (auto _ : state) { + swap(excptr1, excptr2); + benchmark::DoNotOptimize(excptr1); + benchmark::DoNotOptimize(excptr2); + } +} +BENCHMARK(bm_exception_ptr_swap_nonnull); + +void bm_exception_ptr_swap_null(benchmark::State& state) { + std::exception_ptr excptr1 = nullptr; + std::exception_ptr excptr2 = nullptr; + for (auto _ : state) { + swap(excptr1, excptr2); + // The compiler should be able to constant-fold those comparisons + benchmark::DoNotOptimize(excptr1 == nullptr); + benchmark::DoNotOptimize(excptr2 == nullptr); + benchmark::DoNotOptimize(excptr1 == excptr2); + } +} +BENCHMARK(bm_exception_ptr_swap_null); + BENCHMARK_MAIN(); diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp index c448ba8..a1560c8 100644 --- a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp +++ b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp @@ -23,6 +23,11 @@ // __STDC_UTF_16__ may or may not be defined by the C standard library // __STDC_UTF_32__ may or may not be defined by the C standard library +#if !defined(TEST_HAS_NO_C8RTOMB_MBRTOC8) +ASSERT_SAME_TYPE(size_t, decltype(mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); +ASSERT_SAME_TYPE(size_t, decltype(c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); +#endif + ASSERT_SAME_TYPE(size_t, decltype(mbrtoc16((char16_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); ASSERT_SAME_TYPE(size_t, decltype(c16rtomb((char*)0, (char16_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp deleted file mode 100644 index 34b512f..0000000 --- a/libcxx/test/std/depr/depr.c.headers/uchar_h_char8_t.compile.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03 - -// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail -// XFAIL: target={{.+}}-aix{{.*}} -// XFAIL: android -// XFAIL: darwin -// XFAIL: freebsd -// XFAIL: windows -// XFAIL: glibc-no-char8_t-support -// XFAIL: LIBCXX-PICOLIBC-FIXME - -// <uchar.h> - -#include <uchar.h> - -ASSERT_SAME_TYPE(size_t, decltype(mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); -ASSERT_SAME_TYPE(size_t, decltype(c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp index 96b394a..2076384 100644 --- a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp +++ b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp @@ -23,6 +23,11 @@ // __STDC_UTF_16__ may or may not be defined by the C standard library // __STDC_UTF_32__ may or may not be defined by the C standard library +#if !defined(TEST_HAS_NO_C8RTOMB_MBRTOC8) +ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); +ASSERT_SAME_TYPE(std::size_t, decltype(std::c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); +#endif + ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtoc16((char16_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); ASSERT_SAME_TYPE(std::size_t, decltype(std::c16rtomb((char*)0, (char16_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp deleted file mode 100644 index 019265b..0000000 --- a/libcxx/test/std/strings/c.strings/cuchar_char8_t.compile.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03 - -// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail -// XFAIL: target={{.+}}-aix{{.*}} -// XFAIL: android -// XFAIL: darwin -// XFAIL: freebsd -// XFAIL: windows -// XFAIL: glibc-no-char8_t-support -// XFAIL: LIBCXX-PICOLIBC-FIXME - -// <cuchar> - -#include <cuchar> - -ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtoc8((char8_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0))); -ASSERT_SAME_TYPE(std::size_t, decltype(std::c8rtomb((char*)0, (char8_t)0, (mbstate_t*)0))); diff --git a/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp new file mode 100644 index 0000000..1d4a225 --- /dev/null +++ b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03 + +#include <uchar.h> + +#include "test_macros.h" + +// When C++ char8_t support is not enabled, definitions of these functions that +// match the C2X declarations may still be present in the global namespace with +// a char8_t typedef substituted for the C++ char8_t type. If so, these are not +// the declarations we are looking for, so don't test for them. +#if !defined(TEST_HAS_NO_CHAR8_T) +using U = decltype(::c8rtomb); +using V = decltype(::mbrtoc8); +# if !_LIBCPP_HAS_C8RTOMB_MBRTOC8 +// expected-error@-3 {{no member named 'c8rtomb' in the global namespace}} +// expected-error@-3 {{no member named 'mbrtoc8' in the global namespace}} +# else +// expected-no-diagnostics +# endif +#else +// expected-no-diagnostics +#endif |
