From 271c5135f04bd939f7205e2bfb6785a2f87b8c72 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 13 Jun 2025 17:24:09 +0200 Subject: [PATCH 1/2] [libc++] Split libc++-specific tests for the frozen headers --- ...modular_include_in_module.compile.pass.cpp | 21 + .../random_shuffle.cxx1z.pass.cpp | 51 + .../random_shuffle.depr_in_cxx14.verify.cpp | 43 + .../copy_move_nontrivial.pass.cpp | 331 ++ .../copy_move_trivial.pass.cpp | 334 ++ .../copy_move_unwrap_reverse.pass.cpp | 141 + .../make.heap/complexity.pass.cpp | 75 + .../alg.sorting/assert.min.max.pass.cpp | 30 + ...ssert.sort.invalid_comparator.oob.pass.cpp | 72 + .../assert.sort.invalid_comparator.pass.cpp | 195 + .../bad_comparator_values.h | 3565 +++++++++++++++++ .../invalid_comparator_utilities.h | 85 + .../alg.sorting/pstl.is_partitioned.pass.cpp | 31 + .../algorithms/bad_iterator_traits.verify.cpp | 61 + ...lable-requirements-rvalue.compile.pass.cpp | 46 + .../callable-requirements.verify.cpp | 118 + .../cpp17_iterator_concepts.verify.cpp | 425 ++ .../debug_less.inconsistent.pass.cpp | 52 + .../libcxx-03/algorithms/debug_less.pass.cpp | 260 ++ ...debug_three_way_comp.inconsistent.pass.cpp | 56 + .../algorithms/half_positive.pass.cpp | 59 + .../algorithms/lifetimebound.verify.cpp | 81 + .../algorithms/no_specializations.verify.cpp | 28 + .../algorithms/nth_element_stability.pass.cpp | 101 + .../partial_sort_stability.pass.cpp | 102 + .../pstl.iterator-requirements.verify.cpp | 193 + ...pstl.libdispatch.chunk_partitions.pass.cpp | 41 + ...obust_against_copying_comparators.pass.cpp | 264 ++ ...obust_against_copying_projections.pass.cpp | 278 ++ ...obust_against_copying_comparators.pass.cpp | 323 ++ ...t_cpp20_hostile_iterators.compile.pass.cpp | 225 ++ ...using_non_transparent_comparators.pass.cpp | 80 + .../algorithms/sort_stability.pass.cpp | 100 + .../nothrow_forward_iterator.compile.pass.cpp | 27 + .../nothrow_forward_range.compile.pass.cpp | 29 + .../nothrow_input_iterator.compile.pass.cpp | 30 + .../nothrow_input_range.compile.pass.cpp | 32 + .../nothrow_sentinel_for.compile.pass.cpp | 35 + .../algorithms/vectorization.compile.pass.cpp | 34 + ...tomize_verbose_abort.compile-time.pass.cpp | 27 + ...customize_verbose_abort.link-time.pass.cpp | 25 + .../assertions/default_verbose_abort.pass.cpp | 28 + .../libcxx-03/assertions/modes/debug.pass.cpp | 26 + .../assertions/modes/extensive.pass.cpp | 26 + .../libcxx-03/assertions/modes/fast.pass.cpp | 26 + .../hardening_mode_incorrect_value.sh.cpp | 26 + .../libcxx-03/assertions/modes/none.pass.cpp | 32 + .../modes/override_with_debug_mode.pass.cpp | 27 + .../override_with_extensive_mode.pass.cpp | 32 + .../modes/override_with_fast_mode.pass.cpp | 31 + .../override_with_unchecked_mode.pass.cpp | 24 + .../assertions/single_expression.pass.cpp | 34 + .../atomics/atomics.align/align.pass.cpp | 113 + .../atomics/atomics.flag/init_bool.pass.cpp | 43 + .../memory_order.underlying_type.pass.cpp | 34 + .../assert.compare_exchange_strong.pass.cpp | 59 + .../assert.compare_exchange_weak.pass.cpp | 59 + .../atomics/atomics.ref/assert.ctor.pass.cpp | 41 + .../atomics/atomics.ref/assert.load.pass.cpp | 56 + .../atomics/atomics.ref/assert.store.pass.cpp | 64 + .../atomics/atomics.ref/assert.wait.pass.cpp | 56 + .../compare_exchange_strong.verify.cpp | 39 + .../compare_exchange_weak.verify.cpp | 39 + .../atomics/atomics.ref/load.verify.cpp | 34 + .../atomics/atomics.ref/store.verify.cpp | 36 + .../atomics/atomics.ref/wait.verify.cpp | 36 + ...compatible_with_stdatomic.compile.pass.cpp | 23 + .../incompatible_with_stdatomic.verify.cpp | 25 + .../atomics.syn/wait.issue_85107.pass.cpp | 54 + .../atomics.types.float/lockfree.pass.cpp | 51 + .../atomic_fetch_add.verify.cpp | 76 + .../atomic_fetch_add_explicit.verify.cpp | 79 + .../atomic_fetch_sub.verify.cpp | 76 + .../atomic_fetch_sub_explicit.verify.cpp | 79 + .../test/libcxx-03/atomics/bit-int.verify.cpp | 22 + .../diagnose_invalid_memory_order.verify.cpp | 122 + .../dont_hijack_header.compile.pass.cpp | 24 + .../dont_hijack_header.cxx23.compile.pass.cpp | 28 + .../libcxx-03/clang_modules_include.gen.py | 97 + libcxx/test/libcxx-03/clang_tidy.gen.py | 40 + libcxx/test/libcxx-03/clang_tidy.sh.py | 11 + .../__libcpp_integer.compile.pass.cpp | 63 + .../__libcpp_signed_integer.compile.pass.cpp | 63 + ...__libcpp_unsigned_integer.compile.pass.cpp | 63 + .../associative/map/at.abort.pass.cpp | 33 + .../associative/map/at.const.abort.pass.cpp | 33 + .../map/find.modules.compile.pass.mm | 16 + .../associative/map/scary.compile.pass.cpp | 26 + ...non_const_comparator.incomplete.verify.cpp | 56 + .../non_const_comparator.verify.cpp | 48 + .../reference_comparator_abi.compile.pass.cpp | 57 + .../associative/set/scary.compile.pass.cpp | 26 + .../tree_balance_after_insert.pass.cpp | 1612 ++++++++ .../tree_key_value_traits.pass.cpp | 56 + .../associative/tree_left_rotate.pass.cpp | 100 + .../associative/tree_remove.pass.cpp | 1646 ++++++++ .../associative/tree_right_rotate.pass.cpp | 100 + .../unord.map/abi.compile.pass.cpp | 141 + .../unord.map/scary.compile.pass.cpp | 28 + .../unord.set/abi.compile.pass.cpp | 139 + .../unord.set/scary.compile.pass.cpp | 28 + .../flat.map/assert.input_range.pass.cpp | 66 + .../flat.map/assert.sorted_unique.pass.cpp | 225 ++ .../flat.map/scary.compile.pass.cpp | 33 + .../flat.multimap/assert.input_range.pass.cpp | 66 + .../assert.sorted_equivalent.pass.cpp | 225 ++ .../assert.sorted_unique.pass.cpp | 131 + .../flat.multiset/insert.temporary.pass.cpp | 48 + .../flat.multiset/insert_range.pass.cpp | 46 + .../flat.multiset/iterator.compile.pass.cpp | 42 + .../flat.set/assert.sorted_unique.pass.cpp | 226 ++ .../flat.set/insert.temporary.pass.cpp | 48 + .../flat.set/insert_range.pass.cpp | 46 + .../flat.set/iterator.compile.pass.cpp | 42 + .../flat.set/scary.compile.pass.cpp | 33 + .../container.adaptors/flat_helpers.h | 48 + .../container_traits.compile.pass.cpp | 165 + .../containers/gnu_cxx/hash_map.pass.cpp | 36 + .../gnu_cxx/hash_map_name_lookup.pass.cpp | 36 + .../containers/gnu_cxx/hash_set.pass.cpp | 36 + .../gnu_cxx/hash_set_name_lookup.pass.cpp | 36 + .../sequences/array/triviality.pass.cpp | 51 + .../sequences/deque/abi.compile.pass.cpp | 117 + .../containers/sequences/deque/asan.pass.cpp | 68 + .../sequences/deque/asan_caterpillar.pass.cpp | 53 + .../sequences/deque/asan_turning_off.pass.cpp | 77 + .../sequences/deque/assert.pass.cpp | 56 + .../deque/assert.pop_back.empty.pass.cpp | 29 + .../sequences/deque/incomplete.pass.cpp | 34 + .../deque/segmented_iterator.compile.pass.cpp | 12 + .../deque/spare_block_handling.pass.cpp | 288 ++ .../sequences/forwardlist/assert.pass.cpp | 47 + .../forwardlist/bool-conversion.pass.cpp | 37 + .../sequences/list/abi.compile.pass.cpp | 87 + .../list/list.cons/debug.copy.pass.cpp | 30 + .../assert.erase_iter.end.pass.cpp | 29 + .../assert.pop_back.empty.pass.cpp | 35 + .../list.modifiers/bool-conversion.pass.cpp | 37 + .../list.modifiers/debug.emplace.pass.cpp | 34 + .../list.modifiers/debug.erase.iter.pass.cpp | 28 + .../debug.erase.iter_iter.pass.cpp | 57 + .../debug.insert.iter_iter_iter.pass.cpp | 29 + .../debug.insert.iter_rvalue.pass.cpp | 27 + .../debug.insert.iter_size_value.pass.cpp | 27 + .../debug.insert.iter_value.pass.cpp | 28 + .../list.ops/debug.splice.pos_list.pass.cpp | 26 + .../debug.splice.pos_list_iter.pass.cpp | 28 + .../debug.splice.pos_list_iter_iter.pass.cpp | 28 + .../vector.bool/abi.compile.pass.cpp | 69 + .../sequences/vector.bool/assert.pass.cpp | 63 + .../trivial_for_purposes_of_call.pass.cpp | 56 + .../sequences/vector/abi.compile.pass.cpp | 95 + .../containers/sequences/vector/asan.pass.cpp | 76 + .../sequences/vector/asan_throw.pass.cpp | 233 ++ .../vector/asan_turning_off.pass.cpp | 77 + .../vector/assert.back.empty.pass.cpp | 43 + .../vector/assert.cback.empty.pass.cpp | 39 + .../vector/assert.cfront.empty.pass.cpp | 39 + .../vector/assert.cindex.oob.pass.cpp | 42 + .../vector/assert.front.empty.pass.cpp | 44 + .../vector/assert.index.oob.pass.cpp | 42 + .../vector/assert.iterator.add.pass.cpp | 49 + .../vector/assert.iterator.decrement.pass.cpp | 44 + .../assert.iterator.dereference.pass.cpp | 42 + .../vector/assert.iterator.increment.pass.cpp | 47 + .../vector/assert.iterator.index.pass.cpp | 51 + .../vector/assert.pop_back.empty.pass.cpp | 29 + .../vector/debug.iterator.compare.pass.cpp | 39 + .../vector/debug.iterator.subtract.pass.cpp | 39 + .../vector/erase.modules.compile.pass.mm | 16 + ...eption_safety_exceptions_disabled.pass.cpp | 56 + .../sequences/vector/fill_to_capacity.h | 24 + .../vector/invalid_allocator.verify.cpp | 29 + .../vector/robust_against_adl.pass.cpp | 54 + .../vector.cons/construct_iter_iter.pass.cpp | 56 + .../construct_iter_iter_alloc.pass.cpp | 59 + .../strings/basic.string/asan.pass.cpp | 56 + .../asan_deque_integration.pass.cpp | 182 + .../strings/basic.string/asan_short.pass.cpp | 56 + .../basic.string/asan_turning_off.pass.cpp | 102 + .../asan_vector_integration.pass.cpp | 182 + .../unord/key_value_traits.pass.cpp | 60 + .../containers/unord/next_pow2.pass.cpp | 78 + .../containers/unord/next_prime.pass.cpp | 51 + ...non_const_comparator.incomplete.verify.cpp | 58 + .../unord/non_const_comparator.verify.cpp | 58 + .../unord/unord.map/assert.bucket.pass.cpp | 29 + .../unord.map/assert.bucket_size.pass.cpp | 33 + .../assert.iterator.dereference.pass.cpp | 52 + .../assert.iterator.increment.pass.cpp | 59 + ...assert.local_iterator.dereference.pass.cpp | 50 + .../assert.local_iterator.increment.pass.cpp | 66 + .../unord.map/assert.max_load_factor.pass.cpp | 34 + .../unord/unord.map/at.abort.pass.cpp | 32 + .../unord/unord.map/at.const.abort.pass.cpp | 32 + .../debug.insert.hint_const_lvalue.pass.cpp | 41 + .../debug.insert.hint_rvalue.pass.cpp | 35 + .../unord/unord.map/debug.swap.pass.cpp | 38 + .../debug.erase.iter.pass.cpp | 43 + .../debug.erase.iter_iter.pass.cpp | 64 + .../unord.multimap/assert.bucket.pass.cpp | 33 + .../assert.bucket_size.pass.cpp | 33 + .../assert.iterator.dereference.pass.cpp | 52 + .../assert.iterator.increment.pass.cpp | 59 + ...assert.local_iterator.dereference.pass.cpp | 50 + .../assert.local_iterator.increment.pass.cpp | 67 + .../assert.max_load_factor.pass.cpp | 34 + .../debug.insert.hint_const_lvalue.pass.cpp | 33 + .../debug.insert.hint_rvalue.pass.cpp | 34 + .../unord/unord.multimap/debug.swap.pass.cpp | 38 + .../debug.erase.iter.pass.cpp | 43 + .../debug.erase.iter_iter.pass.cpp | 64 + .../unord.multiset/assert.bucket.pass.cpp | 32 + .../assert.bucket_size.pass.cpp | 32 + .../assert.iterator.dereference.pass.cpp | 46 + .../assert.iterator.increment.pass.cpp | 58 + ...assert.local_iterator.dereference.pass.cpp | 48 + .../assert.local_iterator.increment.pass.cpp | 64 + .../assert.max_load_factor.pass.cpp | 33 + .../unord.multiset/debug.erase.iter.pass.cpp | 41 + .../debug.erase.iter_iter.pass.cpp | 60 + .../debug.insert.hint_const_lvalue.pass.cpp | 33 + .../unord/unord.multiset/debug.swap.pass.cpp | 37 + .../unord/unord.set/assert.bucket.pass.cpp | 32 + .../unord.set/assert.bucket_size.pass.cpp | 32 + .../assert.iterator.dereference.pass.cpp | 46 + .../assert.iterator.increment.pass.cpp | 58 + ...assert.local_iterator.dereference.pass.cpp | 48 + .../assert.local_iterator.increment.pass.cpp | 64 + .../unord.set/assert.max_load_factor.pass.cpp | 33 + .../unord/unord.set/debug.erase.iter.pass.cpp | 41 + .../unord.set/debug.erase.iter_iter.pass.cpp | 60 + .../debug.insert.hint_const_lvalue.pass.cpp | 33 + .../unord/unord.set/debug.swap.pass.cpp | 37 + .../missing_hash_specialization.verify.cpp | 70 + .../byte_alignment.verify.cpp | 29 + .../aligned_accessor/element_type.verify.cpp | 32 + .../mdspan/extents/assert.conversion.pass.cpp | 57 + .../extents/assert.ctor_from_array.pass.cpp | 60 + .../assert.ctor_from_integral.pass.cpp | 62 + .../extents/assert.ctor_from_span.pass.cpp | 63 + .../views/mdspan/extents/assert.obs.pass.cpp | 65 + .../layout_left/assert.conversion.pass.cpp | 62 + .../layout_left/assert.ctor.extents.pass.cpp | 38 + .../assert.ctor.layout_right.pass.cpp | 59 + .../assert.ctor.layout_stride.pass.cpp | 83 + .../assert.index_operator.pass.cpp | 84 + .../mdspan/layout_left/assert.stride.pass.cpp | 41 + .../layout_right/assert.conversion.pass.cpp | 62 + .../layout_right/assert.ctor.extents.pass.cpp | 40 + .../assert.ctor.layout_left.pass.cpp | 58 + .../assert.ctor.layout_stride.pass.cpp | 83 + .../assert.index_operator.pass.cpp | 84 + .../layout_right/assert.stride.pass.cpp | 41 + .../layout_stride/assert.conversion.pass.cpp | 111 + ...ert.ctor.extents_array.non_unique.pass.cpp | 67 + .../assert.ctor.extents_array.pass.cpp | 74 + ...sert.ctor.extents_span.non_unique.pass.cpp | 70 + .../assert.ctor.extents_span.pass.cpp | 81 + .../assert.index_operator.pass.cpp | 88 + .../layout_stride/assert.stride.pass.cpp | 36 + .../mdspan/mdspan/assert.conversion.pass.cpp | 66 + .../mdspan/assert.index_operator.pass.cpp | 90 + .../views/mdspan/mdspan/assert.size.pass.cpp | 50 + .../assert.iterator-indexing.pass.cpp | 174 + .../span.cons/assert.iter_sent.pass.cpp | 58 + .../span.cons/assert.iter_size.pass.cpp | 72 + .../span.cons/assert.other_span.pass.cpp | 36 + .../span.cons/assert.range.pass.cpp | 38 + .../views.span/span.elem/assert.back.pass.cpp | 39 + .../span.elem/assert.front.pass.cpp | 39 + .../span.elem/assert.op_idx.pass.cpp | 39 + .../views.span/span.sub/assert.first.pass.cpp | 40 + .../views.span/span.sub/assert.last.pass.cpp | 40 + .../span.sub/assert.subspan.pass.cpp | 61 + .../debug/containers.multithread.pass.cpp | 65 + .../sequence_container_iterators.pass.cpp | 333 ++ .../debug/containers/string.pass.cpp | 92 + .../containers/unord_containers.pass.cpp | 62 + .../auto.ptr/auto_ptr.cxx1z.pass.cpp | 31 + .../auto_ptr.depr_in_cxx11.verify.cpp | 30 + .../depr/depr.c.headers/extern_c.pass.cpp | 53 + .../depr.c.headers/math_h.compile.pass.cpp | 26 + .../stdint_h.std_types_t.compile.pass.cpp | 263 ++ .../stdint_h.xopen_source.compile.pass.cpp | 263 ++ .../allocator.members/address.cxx20.pass.cpp | 44 + .../address.cxx20.verify.cpp | 42 + .../address.depr_in_cxx17.verify.cpp | 26 + .../allocator.members/allocate.cxx20.pass.cpp | 92 + .../allocate.cxx20.verify.cpp | 23 + .../allocate.depr_in_cxx17.verify.cpp | 25 + .../construct.cxx20.pass.cpp | 147 + .../construct.cxx20.verify.cpp | 77 + .../allocator.members/max_size.cxx20.pass.cpp | 34 + .../max_size.cxx20.verify.cpp | 32 + .../allocator_types.cxx20.pass.cpp | 53 + .../typedefs.depr_in_cxx17.verify.cpp | 125 + .../adaptors.depr_in_cxx11.verify.cpp | 51 + .../depr.adaptors.cxx1z.pass.cpp | 68 + .../rel_ops.depr_in_cxx20.verify.cpp | 35 + .../get_unexpected.pass.cpp | 44 + .../set_unexpected.pass.cpp | 40 + .../exception.unexpected/unexpected.pass.cpp | 31 + .../unexpected_disabled_cpp17.verify.cpp | 24 + .../algorithm.nodiscard.verify.cpp | 396 ++ .../diagnostics/array.nodiscard.verify.cpp | 23 + .../diagnostics/bit.nodiscard.verify.cpp | 33 + .../diagnostics/chrono.nodiscard.verify.cpp | 127 + .../diagnostics/cmath.nodiscard.verify.cpp | 167 + .../diagnostics/cstddef.nodiscard.verify.cpp | 20 + .../diagnostics/cstdlib.nodiscard.verify.cpp | 25 + .../diagnostics/deque.nodiscard.verify.cpp | 18 + .../filesystem.nodiscard.verify.cpp | 19 + .../diagnostics/flat_map.nodiscard.verify.cpp | 20 + .../flat_multimap.nodiscard.verify.cpp | 22 + .../flat_multiset.nodiscard.verify.cpp | 20 + .../diagnostics/flat_set.nodiscard.verify.cpp | 20 + .../diagnostics/format.nodiscard.verify.cpp | 49 + .../forward_list.nodiscard.verify.cpp | 18 + .../functional.nodiscard.verify.cpp | 20 + .../diagnostics/future.nodiscard.verify.cpp | 22 + .../diagnostics/iterator.nodiscard.verify.cpp | 38 + .../diagnostics/limits.nodiscard.verify.cpp | 70 + .../diagnostics/list.nodiscard.verify.cpp | 18 + .../diagnostics/map.nodiscard.verify.cpp | 23 + .../diagnostics/memory.nodiscard.verify.cpp | 42 + .../memory_resource.nodiscard.verify.cpp | 25 + .../diagnostics/mutex.nodiscard.verify.cpp | 69 + .../diagnostics/new.nodiscard.verify.cpp | 35 + .../node_handle.nodiscard.verify.cpp | 18 + .../diagnostics/pstl.nodiscard.verify.cpp | 28 + .../diagnostics/queue.nodiscard.verify.cpp | 23 + .../diagnostics/ranges.nodiscard.verify.cpp | 60 + .../diagnostics/regex.nodiscard.verify.cpp | 20 + .../scoped_allocator.nodiscard.verify.cpp | 22 + .../diagnostics/set.nodiscard.verify.cpp | 23 + .../diagnostics/stack.nodiscard.verify.cpp | 18 + .../diagnostics/string.nodiscard.verify.cpp | 18 + .../string_view.nodiscard.verify.cpp | 18 + .../system_error_win_codes.pass.cpp | 25 + .../unordered_map.nodiscard.verify.cpp | 25 + .../unordered_set.nodiscard.verify.cpp | 25 + .../diagnostics/utility.nodiscard.verify.cpp | 35 + .../diagnostics/vector.nodiscard.verify.cpp | 23 + libcxx/test/libcxx-03/double_include.gen.py | 42 + .../fexperimental-library.compile.pass.cpp | 31 + .../hash/specializations.compile.fail.cpp | 18 + .../extensions/hash/specializations.pass.cpp | 36 + .../hash_map/const_iterator.compile.fail.cpp | 19 + .../feature_test_macro/ftm_metadata.sh.py | 82 + .../generate_header_test.sh.py | 637 +++ .../feature_test_macro/implemented_ftms.sh.py | 68 + .../feature_test_macro/invalid.sh.py | 108 + .../feature_test_macro/is_implemented.sh.py | 39 + .../feature_test_macro/standard_ftms.sh.py | 81 + .../standard_library_headers.sh.py | 44 + .../feature_test_macro/std_dialects.sh.py | 39 + .../feature_test_macro/test_data.json | 213 + .../feature_test_macro/version_header.sh.py | 84 + .../version_header_implementation.sh.py | 163 + .../libcxx-03/fuzzing/format_no_args.pass.cpp | 30 + libcxx/test/libcxx-03/fuzzing/fuzz.h | 145 + .../test/libcxx-03/fuzzing/make_heap.pass.cpp | 27 + .../libcxx-03/fuzzing/nth_element.pass.cpp | 42 + .../libcxx-03/fuzzing/partial_sort.pass.cpp | 40 + .../fuzzing/partial_sort_copy.pass.cpp | 41 + .../test/libcxx-03/fuzzing/partition.pass.cpp | 30 + .../libcxx-03/fuzzing/partition_copy.pass.cpp | 65 + .../test/libcxx-03/fuzzing/pop_heap.pass.cpp | 33 + .../test/libcxx-03/fuzzing/push_heap.pass.cpp | 40 + libcxx/test/libcxx-03/fuzzing/random.pass.cpp | 198 + libcxx/test/libcxx-03/fuzzing/regex.pass.cpp | 46 + libcxx/test/libcxx-03/fuzzing/search.pass.cpp | 35 + libcxx/test/libcxx-03/fuzzing/sort.pass.cpp | 27 + .../fuzzing/stable_partition.pass.cpp | 38 + .../libcxx-03/fuzzing/stable_sort.pass.cpp | 39 + libcxx/test/libcxx-03/fuzzing/unique.pass.cpp | 54 + .../libcxx-03/fuzzing/unique_copy.pass.cpp | 56 + .../libcxx-03/gdb/gdb_pretty_printer_test.py | 162 + .../gdb/gdb_pretty_printer_test.sh.cpp | 722 ++++ .../test/libcxx-03/header_inclusions.gen.py | 57 + .../test/libcxx-03/headers_in_modulemap.sh.py | 20 + libcxx/test/libcxx-03/include_as_c.sh.cpp | 59 + .../filebuf/traits_mismatch.verify.cpp | 22 + .../fstreams/fstream.close.pass.cpp | 38 + .../fstream.cons/wchar_pointer.pass.cpp | 52 + .../open_wchar_pointer.pass.cpp | 58 + .../fstreams/ifstream.cons/test.dat | 1 + .../ifstream.cons/wchar_pointer.pass.cpp | 48 + .../open_wchar_pointer.pass.cpp | 54 + .../fstreams/ifstream.members/test.dat | 1 + .../ofstream.cons/wchar_pointer.pass.cpp | 66 + .../open_wchar_pointer.pass.cpp | 66 + .../fstreams/traits_mismatch.verify.cpp | 29 + .../input.output/file.streams/lit.local.cfg | 7 + .../last_write_time.pass.cpp | 104 + .../path.itr/assert.iterator.pass.cpp | 49 + .../path.native.obs/string_alloc.pass.cpp | 173 + .../class.path/path.req/is_pathable.pass.cpp | 107 + .../filesystems/convert_file_time.pass.cpp | 309 ++ .../input.streams/traits_mismatch.verify.cpp | 25 + .../iostream.format/lit.local.cfg | 7 + .../vprint_unicode.pass.cpp | 171 + .../ostream.syn/includes.compile.pass.cpp | 31 + .../output.streams/traits_mismatch.verify.cpp | 25 + .../print.fun/transcoding.pass.cpp | 91 + .../print.fun/vprint_unicode_posix.pass.cpp | 79 + .../print.fun/vprint_unicode_windows.pass.cpp | 135 + .../iostream.objects/lit.local.cfg | 7 + .../ios.base.cons/dtor.uninitialized.pass.cpp | 83 + .../ios/iostate.flags/clear.abort.pass.cpp | 43 + .../input.output/iostreams.base/lit.local.cfg | 7 + .../input.output/stream.buffers/lit.local.cfg | 7 + .../input.output/string.streams/lit.local.cfg | 7 + .../stringbuf/const_sso_buffer.pass.cpp | 171 + .../string.streams/traits_mismatch.verify.cpp | 25 + .../iterators/aliasing_iterator.pass.cpp | 47 + .../iterators/assert.advance.pass.cpp | 37 + .../libcxx-03/iterators/assert.next.pass.cpp | 31 + .../libcxx-03/iterators/assert.prev.pass.cpp | 37 + .../bounded_iter/arithmetic.pass.cpp | 114 + .../bounded_iter/comparison.pass.cpp | 89 + .../bounded_iter/dereference.pass.cpp | 86 + .../bounded_iter/pointer_traits.pass.cpp | 63 + .../bounded_iter/types.compile.pass.cpp | 51 + ...contiguous_iterators.conv.compile.pass.cpp | 65 + .../iterators/contiguous_iterators.pass.cpp | 265 ++ .../iterators/contiguous_iterators.verify.cpp | 27 + .../subsumption.compile.pass.cpp | 29 + .../iterator.operations/prev.verify.cpp | 21 + ...cy_bidirectional_iterator.compile.pass.cpp | 164 + .../legacy_forward_iterator.compile.pass.cpp | 164 + .../legacy_input_iterator.compile.pass.cpp | 164 + .../legacy_iterator.compile.pass.cpp | 164 + ...cy_random_access_iterator.compile.pass.cpp | 164 + .../locale_dependent.compile.pass.cpp | 50 + .../cpp20_iter_concepts.compile.pass.cpp | 81 + .../cpp20_iter_traits.compile.pass.cpp | 34 + .../integer_like.compile.pass.cpp | 51 + .../iterators/iterator_with_data.pass.cpp | 41 + .../counted.iterator/assert.pass.cpp | 42 + .../get_container.pass.cpp | 37 + .../iterators.common/assert.pass.cpp | 58 + .../bad_template_argument.verify.cpp | 22 + .../ostreambuf.iter.ops/failed.pass.cpp | 36 + .../libcxx-03/iterators/unwrap_iter.pass.cpp | 59 + .../cxa_deleted_virtual.pass.cpp | 22 + .../no_specializations.verify.cpp | 23 + .../math.lerp.verify.cpp | 39 + ...new_not_overridden_fno_exceptions.pass.cpp | 58 + .../support.dynamic/libcpp_deallocate.sh.cpp | 255 ++ .../new_dont_return_nullptr.pass.cpp | 37 + ...ype_info.comparison.apple.compile.pass.cpp | 30 + .../type_info.comparison.merged.sh.cpp | 48 + .../type_info.comparison.unmerged.sh.cpp | 45 + .../support.types/cstddef.compile.pass.cpp | 26 + .../timespec_get.xopen.compile.pass.cpp | 21 + libcxx/test/libcxx-03/libcpp_alignof.pass.cpp | 36 + .../test/libcxx-03/libcpp_freestanding.sh.cpp | 20 + libcxx/test/libcxx-03/libcpp_version.gen.py | 34 + .../test/libcxx-03/lint/lint_cmakelists.sh.py | 33 + libcxx/test/libcxx-03/lint/lint_headers.sh.py | 63 + libcxx/test/libcxx-03/lit.local.cfg | 9 + .../test/libcxx-03/localization/lit.local.cfg | 7 + .../locale.categories/__scan_keyword.pass.cpp | 121 + .../locales/locale.abort.pass.cpp | 36 + .../locales/locale.category.abort.pass.cpp | 36 + .../conversions.string/ctor_move.pass.cpp | 42 + .../locale.types/locale.facet/facet.pass.cpp | 56 + .../locale.facet/no_allocation.pass.cpp | 23 + .../locale/locale.types/locale.id/id.pass.cpp | 53 + .../locales/use_facet.abort.pass.cpp | 39 + .../mem/mem.res/nodiscard.verify.cpp | 25 + .../aligned_allocation_macro.compile.pass.cpp | 17 + .../memory/allocation_guard.pass.cpp | 194 + .../allocator_void.trivial.compile.pass.cpp | 26 + .../memory/allocator_volatile.verify.cpp | 14 + .../libcxx-03/memory/is_allocator.pass.cpp | 43 + .../memory/shared_ptr_array.pass.cpp | 33 + .../libcxx-03/memory/swap_allocator.pass.cpp | 83 + .../trivial_abi/shared_ptr_arg.pass.cpp | 51 + .../trivial_abi/unique_ptr_arg.pass.cpp | 52 + .../trivial_abi/unique_ptr_array.pass.cpp | 57 + .../unique_ptr_destruction_order.pass.cpp | 68 + .../trivial_abi/unique_ptr_ret.pass.cpp | 59 + .../memory/trivial_abi/weak_ptr_ret.pass.cpp | 62 + .../uninitialized_allocator_copy.pass.cpp | 67 + .../minimal_cxx11_configuration.pass.cpp | 130 + libcxx/test/libcxx-03/module_std.gen.py | 38 + .../test/libcxx-03/module_std_compat.gen.py | 42 + .../test/libcxx-03/no_assert_include.gen.py | 39 + .../test/libcxx-03/numerics/bit.ops.pass.cpp | 45 + .../c.math/constexpr-cxx23-clang.pass.cpp | 266 ++ .../c.math/constexpr-cxx23-gcc.pass.cpp | 256 ++ .../numerics/c.math/constexpr-fns.pass.cpp | 29 + .../c.math/fdelayed-template-parsing.pass.cpp | 28 + .../numerics/clamp_to_integral.pass.cpp | 94 + .../numerics/complex.number/__sqr.pass.cpp | 84 + .../complex.number/cmplx.over.pow.pass.cpp | 86 + .../numerics/numarray/assert.pass.cpp | 42 + .../class.gslice.array/assert.get.pass.cpp | 49 + .../numarray/class.gslice.array/get.pass.cpp | 52 + .../class.indirect.array/assert.get.pass.cpp | 49 + .../class.indirect.array/get.pass.cpp | 44 + .../class.mask.array/assert.get.pass.cpp | 48 + .../numarray/class.mask.array/get.pass.cpp | 51 + .../class.slice.array/assert.get.pass.cpp | 49 + .../numarray/class.slice.array/get.pass.cpp | 46 + .../numeric.ops/midpoint.integer.pass.cpp | 69 + .../has-no-random-device.verify.cpp | 18 + .../bad_engine.verify.cpp | 30 + .../rand.dist.bern.bin/bad_engine.verify.cpp | 30 + .../rand.dist.bern.geo/bad_engine.verify.cpp | 31 + .../bad_engine.verify.cpp | 31 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../rand.dist.norm.f/bad_engine.verify.cpp | 31 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../rand.dist.norm.t/bad_engine.verify.cpp | 30 + .../rand.dist.pois.exp/bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 31 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../bad_engine.verify.cpp | 30 + .../rand.dist.uni.int/bad_engine.verify.cpp | 31 + .../rand.dist.uni.real/bad_engine.verify.cpp | 30 + .../rand.req.urng/valid_int_type.verify.cpp | 51 + .../rand.req.urng/valid_real_type.verify.cpp | 109 + .../libcxx-03/odr_signature.exceptions.sh.cpp | 46 + .../libcxx-03/odr_signature.hardening.sh.cpp | 67 + .../ranges/no_specializations.verify.cpp | 25 + .../range.access/end.incomplete_type.pass.cpp | 46 + .../as-lvalue.lifetimebound.verify.cpp | 22 + .../range.adaptor.helpers/as-lvalue.pass.cpp | 41 + .../tuple-for-each.pass.cpp | 31 + .../range.all/all.nodiscard.verify.cpp | 21 + .../range.chunk.by/assert.begin.pass.cpp | 35 + .../range.chunk.by/assert.find-next.pass.cpp | 38 + .../range.chunk.by/assert.find-prev.pass.cpp | 49 + .../no_unique_address.compile.pass.cpp | 46 + .../range.chunk.by.iter/assert.deref.pass.cpp | 30 + .../assert.increment.pass.cpp | 30 + .../range.adaptors/range.chunk.by/types.h | 23 + .../adaptor.nodiscard.verify.cpp | 21 + .../adaptor.nodiscard.verify.cpp | 19 + .../range.drop.while/assert.begin.pass.cpp | 49 + ...ts_view.no_unique_address.compile.pass.cpp | 33 + ...entinel.no_unique_address.compile.pass.cpp | 37 + .../ctor.parent.outer.pass.cpp | 65 + .../range.join.iterator/ctor.parent.pass.cpp | 36 + .../range.join/range.join.iterator/types.h | 114 + .../segmented_iterator.compile.pass.cpp | 17 + .../no_unique_address.compile.pass.cpp | 116 + .../assert.equal.pass.cpp | 37 + .../assert.equal.pass.cpp | 37 + .../range.adaptors/range.lazy.split/types.h | 73 + .../range.move.wrap/arrow.pass.cpp | 54 + .../range.move.wrap/assign.copy.pass.cpp | 168 + .../range.move.wrap/assign.move.pass.cpp | 228 ++ .../range.move.wrap/ctor.default.pass.cpp | 65 + .../range.move.wrap/ctor.in_place.pass.cpp | 69 + .../range.move.wrap/deref.pass.cpp | 52 + .../range.move.wrap/empty_object.pass.cpp | 56 + .../range.move.wrap/has_value.pass.cpp | 48 + .../no_unique_address.pass.cpp | 78 + .../properties.compile.pass.cpp | 61 + .../range.adaptors/range.move.wrap/types.h | 157 + .../adaptor.nodiscard.verify.cpp | 21 + .../no_unique_address.compile.pass.cpp | 26 + .../adaptor.nodiscard.verify.cpp | 23 + .../no_unique_address.compile.pass.cpp | 22 + .../range.repeat.view/ctor.piecewise.pass.cpp | 32 + .../ctor.value.bound.pass.cpp | 29 + .../no_unique_address.compile.pass.cpp | 23 + .../no_unique_address.compile.pass.cpp | 23 + .../range.nonprop.cache/assign.copy.pass.cpp | 102 + .../range.nonprop.cache/assign.move.pass.cpp | 98 + .../constraints.compile.pass.cpp | 28 + .../range.nonprop.cache/ctor.copy.pass.cpp | 73 + .../range.nonprop.cache/ctor.default.pass.cpp | 41 + .../range.nonprop.cache/ctor.move.pass.cpp | 64 + .../ranges/range.nonprop.cache/deref.pass.cpp | 53 + .../range.nonprop.cache/emplace.pass.cpp | 95 + .../range.nonprop.cache/emplace_from.pass.cpp | 77 + .../range.nonprop.cache/has_value.pass.cpp | 46 + .../different_from.compile.pass.cpp | 27 + .../has_arrow.compile.pass.cpp | 83 + .../simple_view.compile.pass.cpp | 58 + .../to.internal_constraints.verify.cpp | 94 + .../to.static_assert.verify.cpp | 92 + .../conditional-compile-flags.sh.cpp | 14 + .../additional_compile_flags/lit.local.cfg | 2 + .../substitutes-in-compile-flags.sh.cpp | 18 + .../substitutes-in-run.sh.cpp | 15 + .../compile-error.compile.fail.cpp | 14 + .../compile-success.compile.fail.cpp | 13 + .../compile-error.compile.pass.cpp | 16 + .../compile-success.compile.pass.cpp | 11 + .../link-error.compile.pass.cpp | 16 + .../run-error.compile.pass.cpp | 13 + .../compile-error.compile.pass.mm | 18 + .../compile-success.compile.pass.mm | 16 + .../link-error.compile.pass.mm | 21 + .../compile.pass.mm/run-error.compile.pass.mm | 18 + .../build_run.sh.cpp | 23 + .../convenience_substitutions/verify.sh.cpp | 16 + libcxx/test/libcxx-03/selftest/dsl/dsl.sh.py | 629 +++ .../test/libcxx-03/selftest/dsl/lit.local.cfg | 15 + .../selftest/file_dependencies/a.txt | 0 .../absolute-and-relative-paths.sh.cpp | 15 + .../selftest/file_dependencies/dir/b.txt | 0 .../substitute-in-dependencies.sh.cpp | 12 + .../libcxx-03/selftest/gen.cpp/empty.gen.cpp | 11 + .../libcxx-03/selftest/gen.cpp/one.gen.cpp | 11 + .../libcxx-03/selftest/gen.cpp/two.gen.cpp | 12 + .../link.fail.cpp/compile-error.link.fail.cpp | 16 + .../link.fail.cpp/link-error.link.fail.cpp | 16 + .../link.fail.cpp/link-success.link.fail.cpp | 13 + .../link.pass.cpp/compile-error.link.pass.cpp | 16 + .../link.pass.cpp/link-error.link.pass.cpp | 18 + .../link.pass.cpp/link-success.link.pass.cpp | 11 + .../link.pass.cpp/run-error.link.pass.cpp | 14 + .../link.pass.mm/compile-error.link.pass.mm | 18 + .../link.pass.mm/link-error.link.pass.mm | 20 + .../link.pass.mm/link-success.link.pass.mm | 16 + .../link.pass.mm/run-error.link.pass.mm | 19 + .../selftest/modules/no-modules.sh.cpp | 14 + .../modules/std-and-std.compat-module.sh.cpp | 22 + .../selftest/modules/std-module.sh.cpp | 24 + .../selftest/modules/std.compat-module.sh.cpp | 24 + .../selftest/pass.cpp/compile-error.pass.cpp | 16 + .../selftest/pass.cpp/link-error.pass.cpp | 18 + .../selftest/pass.cpp/run-error.pass.cpp | 15 + .../selftest/pass.cpp/run-success.pass.cpp | 13 + .../selftest/pass.cpp/werror.pass.cpp | 22 + .../selftest/pass.mm/compile-error.pass.mm | 18 + .../selftest/pass.mm/link-error.pass.mm | 20 + .../libcxx-03/selftest/pass.mm/no-arc.pass.mm | 19 + .../selftest/pass.mm/run-error.pass.mm | 17 + .../selftest/pass.mm/run-success.pass.mm | 15 + .../pass.mm/use-objective-cxx.pass.mm | 18 + .../selftest/remote-substitutions.sh.cpp | 32 + .../selftest/sh.cpp/run-error.sh.cpp | 13 + .../selftest/sh.cpp/run-success.sh.cpp | 11 + .../selftest/sh.cpp/substitutions.sh.cpp | 24 + .../libcxx-03/selftest/sh.cpp/werror.sh.cpp | 23 + .../selftest/shell-no-escape-builtins.sh.cpp | 12 + .../libcxx-03/selftest/stdin-is-piped.sh.cpp | 22 + .../libcxx-03/selftest/test_macros.pass.cpp | 41 + .../libcxx-03/selftest/tmpdir-exists.sh.cpp | 11 + .../no-diagnostics-unmarked.verify.cpp | 17 + .../verify.cpp/no-diagnostics.verify.cpp | 11 + .../selftest/verify.cpp/no-werror.verify.cpp | 15 + .../verify.cpp/right-diagnostic.verify.cpp | 12 + .../verify.cpp/wrong-diagnostic.verify.cpp | 14 + .../basic.string/alignof.compile.pass.cpp | 146 + .../strings/basic.string/nonnull.verify.cpp | 41 + .../basic.string/sizeof.compile.pass.cpp | 145 + .../string.access/assert.back.pass.cpp | 34 + .../string.access/assert.cback.pass.cpp | 34 + .../string.access/assert.cfront.pass.cpp | 34 + .../string.access/assert.cindex.pass.cpp | 36 + .../string.access/assert.front.pass.cpp | 35 + .../string.access/assert.index.pass.cpp | 36 + .../string.capacity/PR53170.pass.cpp | 84 + .../string.capacity/allocation_size.pass.cpp | 37 + .../string.capacity/max_size.pass.cpp | 122 + .../string.capacity/shrink_to_fit.pass.cpp | 87 + .../constinit_sso_string.compile.pass.cpp | 25 + .../string.cons/copy_shrunk_long.pass.cpp | 45 + .../debug.iterator.substr.pass.cpp | 49 + .../assert.iterator.add.pass.cpp | 37 + .../assert.iterator.decrement.pass.cpp | 36 + .../assert.iterator.dereference.pass.cpp | 33 + .../assert.iterator.increment.pass.cpp | 36 + .../assert.iterator.index.pass.cpp | 37 + .../debug.iterator.compare.pass.cpp | 33 + .../debug.iterator.subtract.pass.cpp | 33 + .../assert.erase_iter.null.pass.cpp | 35 + .../string.modifiers/assert.pop_back.pass.cpp | 32 + .../debug.erase.iter.pass.cpp | 35 + .../debug.erase.iter_iter.pass.cpp | 61 + .../debug.insert.iter_char.pass.cpp | 39 + .../debug.insert.iter_iter_iter.pass.cpp | 35 + .../debug.insert.iter_size_char.pass.cpp | 32 + .../resize_default_initialized.pass.cpp | 75 + .../constexpr.cstring.compile.pass.cpp | 31 + .../constexpr.cwchar.compile.pass.cpp | 26 + .../c.strings/constexpr_memmove.pass.cpp | 157 + .../string.view/assert.ctor.length.pass.cpp | 26 + .../string.view/assert.ctor.pointer.pass.cpp | 41 + .../assert.iterator-indexing.pass.cpp | 158 + .../libcxx-03/system_reserved_names.gen.py | 206 + .../thread/atomic.availability.verify.cpp | 77 + .../thread/barrier.availability.verify.cpp | 41 + .../assert.set_exception.pass.cpp | 40 + ...sert.set_exception_at_thread_exit.pass.cpp | 40 + .../futures/futures.task/type.depr.verify.cpp | 28 + .../futures/futures.task/types.pass.cpp | 34 + .../thread/latch.availability.verify.cpp | 23 + .../thread/semaphore.availability.verify.cpp | 48 + .../thread.barrier/assert.arrive.pass.cpp | 40 + .../thread.barrier/assert.ctor.pass.cpp | 48 + ...otify_from_pthread_created_thread.pass.cpp | 78 + .../native_handle.pass.cpp | 36 + .../assert.arrive_and_wait.pass.cpp | 37 + .../thread.latch/assert.count_down.pass.cpp | 45 + .../thread/thread.latch/assert.ctor.pass.cpp | 38 + .../thread.mutex.class/native_handle.pass.cpp | 32 + .../native_handle.pass.cpp | 32 + ...ad_safety_annotations_not_enabled.pass.cpp | 30 + .../thread_safety_lock_guard.pass.cpp | 40 + .../thread_safety_lock_unlock.pass.cpp | 33 + .../thread_safety_missing_unlock.verify.cpp | 26 + ...thread_safety_requires_capability.pass.cpp | 37 + .../thread.semaphore/assert.ctor.pass.cpp | 37 + .../thread.semaphore/assert.release.pass.cpp | 41 + .../thread_safety.verify.cpp | 64 + .../thread_safety.verify.cpp | 95 + .../atomic_unique_lock.pass.cpp | 95 + .../intrusive_list_view.pass.cpp | 108 + .../intrusive_shared_ptr.pass.cpp | 88 + .../thread.threads/create_late.pass.cpp | 29 + .../native_handle.pass.cpp | 59 + .../thread.thread.class/types.pass.cpp | 31 + .../thread.thread.this/sleep_for.pass.cpp | 35 + .../sleep_for.signals.pass.cpp | 67 + .../libcxx-03/time/convert_to_tm.pass.cpp | 63 + .../assert.from_utc.pass.cpp | 73 + .../assert.to_utc.pass.cpp | 73 + .../assert.from_utc.pass.cpp | 73 + .../assert.to_utc.pass.cpp | 73 + .../get_leap_second_info.pass.cpp | 147 + .../time.clock.utc.members/from_sys.pass.cpp | 108 + .../time.clock.utc.members/to_sys.pass.cpp | 117 + .../time.zone.db/leap_seconds.pass.cpp | 126 + .../time.zone/time.zone.db/links.pass.cpp | 102 + .../time.zone/time.zone.db/rules.pass.cpp | 594 +++ .../time.zone.db.list/erase_after.pass.cpp | 71 + .../time.zone.db.remote/reload_tzdb.pass.cpp | 58 + .../time.zone.db.tzdb/locate_zone.pass.cpp | 84 + .../time.zone/time.zone.db/version.pass.cpp | 74 + .../time.zone/time.zone.db/zones.pass.cpp | 380 ++ .../assert.ctor.pass.cpp | 53 + .../assert.ctor.pass.cpp | 53 + .../time.zone.info.local/ostream.pass.cpp | 114 + .../time.zone.info.sys/ostream.pass.cpp | 74 + .../time.zone.timezone/choose.pass.cpp | 37 + .../assert.to_local.pass.cpp | 40 + .../time.zone.members/assert.to_sys.pass.cpp | 39 + .../assert.to_sys_choose.pass.cpp | 41 + .../get_info.sys_time.pass.cpp | 204 + .../get_info.sys_time.rule_selection.pass.cpp | 185 + .../test/libcxx-03/transitive_includes.gen.py | 102 + .../libcxx-03/transitive_includes/cxx03.csv | 2568 ++++++++++++ .../libcxx-03/transitive_includes/cxx11.csv | 2568 ++++++++++++ .../libcxx-03/transitive_includes/cxx14.csv | 2619 ++++++++++++ .../libcxx-03/transitive_includes/cxx17.csv | 2621 ++++++++++++ .../libcxx-03/transitive_includes/cxx20.csv | 2649 ++++++++++++ .../libcxx-03/transitive_includes/cxx23.csv | 1166 ++++++ .../libcxx-03/transitive_includes/cxx26.csv | 1167 ++++++ .../libcxx-03/transitive_includes/to_csv.py | 120 + .../type_traits/convert_to_integral.pass.cpp | 123 + .../type_traits/datasizeof.compile.pass.cpp | 62 + .../type_traits/desugars_to.compile.pass.cpp | 42 + .../is_always_bitcastable.compile.pass.cpp | 219 + .../type_traits/is_callable.compile.pass.cpp | 31 + .../is_constant_evaluated.pass.cpp | 36 + ..._implicitly_default_constructible.pass.cpp | 81 + .../type_traits/is_pointer.arc.pass.mm | 75 + .../is_replaceable.compile.pass.cpp | 313 ++ .../type_traits/is_scalar.objc.pass.mm | 38 + .../is_specialization.compile.pass.cpp | 55 + .../type_traits/is_specialization.verify.cpp | 21 + .../is_trivially_comparable.compile.pass.cpp | 67 + .../is_trivially_relocatable.compile.pass.cpp | 243 ++ .../type_traits/lazy_metafunctions.pass.cpp | 131 + .../type_traits/no_specializations.verify.cpp | 197 + .../utilities/any/allocator.pass.cpp | 127 + .../utilities/any/size_and_alignment.pass.cpp | 25 + .../utilities/any/small_type.pass.cpp | 115 + ...ert.exception_guard.no_exceptions.pass.cpp | 22 + .../exception_guard.no_exceptions.pass.cpp | 22 + .../utilities/exception_guard.odr.sh.cpp | 45 + .../utilities/exception_guard.pass.cpp | 161 + .../and_then.mandates.verify.cpp | 126 + .../expected.expected/assert.arrow.pass.cpp | 30 + .../expected.expected/assert.deref.pass.cpp | 34 + .../expected.expected/assert.error.pass.cpp | 34 + .../error_or.mandates.verify.cpp | 72 + .../no_unique_address.compile.pass.cpp | 75 + .../noexcept.extension.compile.pass.cpp | 125 + .../or_else.mandates.verify.cpp | 125 + .../transform_error.mandates.verify.cpp | 99 + .../value.observers.verify.cpp | 131 + .../value_or.mandates.verify.cpp | 66 + .../class.mandates.verify.cpp | 25 + .../noexcept.extension.compile.pass.cpp | 46 + .../swap.mandates.verify.cpp | 26 + .../and_then.mandates.verify.cpp | 125 + .../expected.void/assert.deref.pass.cpp | 28 + .../expected.void/assert.error.pass.cpp | 34 + .../error_or.mandates.verify.cpp | 71 + .../no_unique_address.compile.pass.cpp | 68 + .../noexcept.extension.compile.pass.cpp | 81 + .../expected.void/or_else.mandates.verify.cpp | 121 + .../transform_error.mandates.verify.cpp | 102 + .../expected.void/value.lwg3940.verify.cpp | 51 + .../test/libcxx-03/utilities/expected/types.h | 51 + .../utilities/expol/policies.compile.pass.cpp | 44 + .../format/enable_insertable.compile.pass.cpp | 151 + .../format.arg/arg_t.compile.pass.cpp | 39 + .../format.arg/assert.array.pass.cpp | 33 + .../format.context/types.compile.pass.cpp | 128 + .../format/format.functions/ascii.pass.cpp | 161 + .../escaped_output.ascii.pass.cpp | 352 ++ .../code_point_width_estimation.pass.cpp | 86 + .../format.string.std/concepts_precision.h | 22 + .../format.string.std/escaped_output.pass.cpp | 104 + .../extended_grapheme_cluster.h | 3382 ++++++++++++++++ .../extended_grapheme_cluster.pass.cpp | 107 + .../format.string.std/test_exception.h | 52 + .../format/no_specializations.verify.cpp | 23 + .../func.bind.partial/bind_back.pass.cpp | 416 ++ .../func.bind.partial/compose.pass.cpp | 81 + .../function.objects/func.blocks.arc.pass.mm | 89 + .../function.objects/func.blocks.pass.cpp | 147 + .../func.not.fn/not_fn.nttp.compile.pass.cpp | 43 + .../not_fn.nttp.nodiscard.verify.cpp | 24 + .../func.require/bullet_1_2_3.pass.cpp | 405 ++ .../func.require/bullet_4_5_6.pass.cpp | 210 + .../func.require/bullet_7.pass.cpp | 328 ++ .../func.require/invoke.pass.cpp | 46 + .../func.require/invoke_helpers.h | 375 ++ .../move_reentrant.pass.cpp | 52 + .../nullptr_t_assign_reentrant.pass.cpp | 52 + .../function.objects/refwrap/binary.pass.cpp | 87 + .../refwrap/desugars_to.compile.pass.cpp | 36 + .../refwrap/layout.binary.compile.pass.cpp | 21 + .../refwrap/layout.unary.compile.pass.cpp | 22 + .../function.objects/refwrap/unary.pass.cpp | 85 + ...h_ubsan_unsigned_overflow_ignored.pass.cpp | 43 + .../intseq/for_each_index_sequence.pass.cpp | 33 + .../utilities/is_pointer_in_range.pass.cpp | 58 + .../utilities/is_valid_range.pass.cpp | 70 + .../pointer.conversion/to_address.pass.cpp | 159 + .../to_address_on_funcptr.verify.cpp | 20 + .../to_address_on_function.verify.cpp | 20 + .../to_address_std_iterators.pass.cpp | 56 + .../assume_aligned.const_eval.verify.cpp | 48 + .../assume_aligned.power2.verify.cpp | 31 + .../util.smartptr/race_condition.pass.cpp | 99 + .../function_type_default_deleter.verify.cpp | 54 + .../libcxx.control_block_layout.pass.cpp | 232 ++ ...te_shared.array.zero_size.compile.fail.cpp | 22 + ...ke_shared.array.zero_size.compile.fail.cpp | 22 + .../meta/is_referenceable.compile.pass.cpp | 192 + .../utilities/meta/meta_base.pass.cpp | 92 + .../stress_tests/stress_test_is_same.sh.cpp | 55 + .../stress_test_metafunctions.sh.cpp | 65 + .../stress_test_variant_overloads_impl.sh.cpp | 119 + .../libcxx-03/utilities/no_destroy.pass.cpp | 33 + .../utilities/optional/block.objc.pass.mm | 28 + .../optional.object.assign/copy.pass.cpp | 78 + .../optional.object.assign/move.pass.cpp | 75 + .../optional.object.ctor/copy.pass.cpp | 62 + .../optional.object.ctor/move.pass.cpp | 63 + .../assert.dereference.pass.cpp | 51 + .../assert.op_arrow.pass.cpp | 39 + .../optional.object/optional_size.pass.cpp | 31 + .../optional.object/triviality.abi.pass.cpp | 101 + .../smartptr/unique.ptr/null.pass.cpp | 84 + .../utilities/template.bitset/assert.pass.cpp | 42 + .../template.bitset/includes.pass.cpp | 33 + .../tuple/__tuple_like.compile.pass.cpp | 95 + .../tuple/no_specializations.verify.cpp | 23 + .../tuple/tuple.tuple/empty_member.pass.cpp | 49 + .../tuple.assign/array.extension.pass.cpp | 104 + .../tuple_array_template_depth.pass.cpp | 37 + ...5_tuple_ref_binding_diagnostics.verify.cpp | 74 + .../utility/__is_inplace_index.pass.cpp | 37 + .../utility/__is_inplace_type.pass.cpp | 37 + .../__murmur2_or_cityhash.abi-v1.pass.cpp | 50 + .../__murmur2_or_cityhash.abi-v2.pass.cpp | 47 + .../utility/forward/lifetimebound.verify.cpp | 28 + .../allocate_vocabulary.attributes.verify.cpp | 19 + .../assert.deallocate.pass.cpp | 41 + .../construct_piecewise_pair.pass.cpp | 170 + ...allocate_from_underaligned_buffer.pass.cpp | 61 + ...allocate_in_geometric_progression.pass.cpp | 34 + .../unsynchronized_buffer.pass.cpp | 211 + .../mem.res/pmr.availability.verify.cpp | 63 + .../utility/pairs/pairs.pair/U_V.pass.cpp | 58 + .../abi.non_trivial_copy_move.pass.cpp | 154 + .../pairs.pair/abi.trivial_copy_move.pass.cpp | 182 + .../abi.trivially_copyable.compile.pass.cpp | 68 + .../pairs.pair/assign_tuple_like.pass.cpp | 100 + .../const_first_const_second.pass.cpp | 63 + .../pairs/pairs.pair/const_pair_U_V.pass.cpp | 68 + .../utility/pairs/pairs.pair/default.pass.cpp | 39 + .../pair.incomplete.compile.pass.cpp | 22 + .../pairs.pair/pair.tuple_element.verify.cpp | 21 + .../pairs/pairs.pair/piecewise.pass.cpp | 41 + .../pairs/pairs.pair/rv_pair_U_V.pass.cpp | 66 + .../private_constructor_tag.compile.pass.cpp | 22 + .../utilities/utility/small_buffer.pass.cpp | 74 + .../variant/no_specializations.verify.cpp | 23 + .../variant_alternative.verify.cpp | 37 + .../variant.variant/variant_size.pass.cpp | 88 + ...lity-with-pedantic-errors.compile.pass.cpp | 22 + .../vendor/apple/disable-availability.sh.cpp | 49 + .../apple/system-install-properties.sh.cpp | 46 + .../vendor/clang-cl/static-lib-exports.sh.cpp | 16 + .../vendor/ibm/bad_function_call.pass.cpp | 45 + .../vendor/mingw/static-lib-exports.sh.cpp | 16 + libcxx/test/libcxx-03/xopen_source.gen.py | 56 + libcxx/test/libcxx/lit.local.cfg | 4 + 921 files changed, 84519 insertions(+) create mode 100644 libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_unwrap_reverse.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/assert.min.max.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.oob.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/bad_comparator_values.h create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/invalid_comparator_utilities.h create mode 100644 libcxx/test/libcxx-03/algorithms/alg.sorting/pstl.is_partitioned.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/callable-requirements-rvalue.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/callable-requirements.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/cpp17_iterator_concepts.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/debug_less.inconsistent.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/debug_less.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/debug_three_way_comp.inconsistent.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/lifetimebound.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/nth_element_stability.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/partial_sort_stability.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/pstl.iterator-requirements.verify.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_comparators.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_projections.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/robust_against_copying_comparators.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/robust_against_using_non_transparent_comparators.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/sort_stability.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_range.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/algorithms/vectorization.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/customize_verbose_abort.link-time.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/debug.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/extensive.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/fast.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/none.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/override_with_debug_mode.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/override_with_extensive_mode.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/override_with_fast_mode.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/modes/override_with_unchecked_mode.pass.cpp create mode 100644 libcxx/test/libcxx-03/assertions/single_expression.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.align/align.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.flag/init_bool.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/assert.load.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/assert.store.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/assert.wait.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_strong.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_weak.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/load.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/store.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.ref/wait.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.syn/wait.issue_85107.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/bit-int.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp create mode 100644 libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/clang_modules_include.gen.py create mode 100644 libcxx/test/libcxx-03/clang_tidy.gen.py create mode 100644 libcxx/test/libcxx-03/clang_tidy.sh.py create mode 100644 libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/map/at.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/map/at.const.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/map/find.modules.compile.pass.mm create mode 100644 libcxx/test/libcxx-03/containers/associative/map/scary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/non_const_comparator.incomplete.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/non_const_comparator.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/reference_comparator_abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/set/scary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/tree_balance_after_insert.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/tree_key_value_traits.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/tree_left_rotate.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/tree_remove.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/tree_right_rotate.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/unord.map/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/unord.map/scary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/unord.set/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/associative/unord.set/scary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.map/assert.input_range.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.map/assert.sorted_unique.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.map/scary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.multimap/assert.input_range.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.multimap/assert.sorted_equivalent.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.multiset/assert.sorted_unique.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.multiset/insert.temporary.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.multiset/insert_range.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.multiset/iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.set/assert.sorted_unique.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.set/insert.temporary.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.set/insert_range.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.set/iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat.set/scary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/container.adaptors/flat_helpers.h create mode 100644 libcxx/test/libcxx-03/containers/container_traits.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/gnu_cxx/hash_map.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/gnu_cxx/hash_map_name_lookup.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/gnu_cxx/hash_set.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/gnu_cxx/hash_set_name_lookup.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/array/triviality.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/asan.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/asan_caterpillar.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/asan_turning_off.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/assert.pop_back.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/incomplete.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/segmented_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/deque/spare_block_handling.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/forwardlist/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/forwardlist/bool-conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.cons/debug.copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/bool-conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector.bool/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector.bool/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector.bool/trivial_for_purposes_of_call.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/abi.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/asan.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/asan_throw.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/asan_turning_off.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.back.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.cback.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.cfront.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.cindex.oob.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.front.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.index.oob.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.iterator.add.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.iterator.decrement.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.iterator.index.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/assert.pop_back.empty.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/debug.iterator.compare.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/debug.iterator.subtract.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/erase.modules.compile.pass.mm create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/exception_safety_exceptions_disabled.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/fill_to_capacity.h create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/invalid_allocator.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/robust_against_adl.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/strings/basic.string/asan.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/strings/basic.string/asan_deque_integration.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/strings/basic.string/asan_short.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/strings/basic.string/asan_turning_off.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/strings/basic.string/asan_vector_integration.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/key_value_traits.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/next_pow2.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/next_prime.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/non_const_comparator.incomplete.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/non_const_comparator.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.bucket.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.bucket_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.local_iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.local_iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/assert.max_load_factor.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/at.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/at.const.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/debug.swap.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.bucket.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.bucket_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.local_iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.local_iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/debug.swap.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.bucket.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.bucket_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.local_iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.local_iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/debug.erase.iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.multiset/debug.swap.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.bucket.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.bucket_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.local_iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.local_iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/assert.max_load_factor.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/debug.erase.iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/debug.swap.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/unord/unord.set/missing_hash_specialization.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/aligned_accessor/byte_alignment.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/aligned_accessor/element_type.verify.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/extents/assert.conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/extents/assert.obs.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_left/assert.conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_left/assert.ctor.layout_stride.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_left/assert.stride.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_right/assert.conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_right/assert.ctor.layout_stride.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_right/assert.stride.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.ctor.extents_array.non_unique.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.ctor.extents_array.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.ctor.extents_span.non_unique.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.ctor.extents_span.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.index_operator.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/layout_stride/assert.stride.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/mdspan/assert.conversion.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/mdspan/assert.index_operator.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/mdspan/mdspan/assert.size.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/assert.iterator-indexing.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.cons/assert.iter_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.cons/assert.other_span.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.cons/assert.range.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.elem/assert.back.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.elem/assert.front.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.elem/assert.op_idx.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.sub/assert.first.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.sub/assert.last.pass.cpp create mode 100644 libcxx/test/libcxx-03/containers/views/views.span/span.sub/assert.subspan.pass.cpp create mode 100644 libcxx/test/libcxx-03/debug/containers.multithread.pass.cpp create mode 100644 libcxx/test/libcxx-03/debug/containers/sequence_container_iterators.pass.cpp create mode 100644 libcxx/test/libcxx-03/debug/containers/string.pass.cpp create mode 100644 libcxx/test/libcxx-03/debug/containers/unord_containers.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.c.headers/extern_c.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.c.headers/math_h.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.c.headers/stdint_h.std_types_t.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/address.cxx20.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/address.cxx20.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/address.depr_in_cxx17.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/allocate.cxx20.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/allocate.cxx20.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/allocate.depr_in_cxx17.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/construct.cxx20.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/construct.cxx20.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/max_size.cxx20.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/max_size.cxx20.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.default.allocator/allocator_types.cxx20.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.func.adaptor.typedefs/typedefs.depr_in_cxx17.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.function.objects/adaptors.depr_in_cxx11.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/depr.rel_ops/rel_ops.depr_in_cxx20.verify.cpp create mode 100644 libcxx/test/libcxx-03/depr/exception.unexpected/get_unexpected.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/exception.unexpected/set_unexpected.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/exception.unexpected/unexpected.pass.cpp create mode 100644 libcxx/test/libcxx-03/depr/exception.unexpected/unexpected_disabled_cpp17.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/algorithm.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/array.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/bit.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/chrono.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/cmath.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/cstddef.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/cstdlib.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/deque.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/filesystem.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/flat_map.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/flat_multimap.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/flat_multiset.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/flat_set.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/format.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/forward_list.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/functional.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/future.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/iterator.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/limits.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/list.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/map.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/memory.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/memory_resource.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/mutex.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/new.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/node_handle.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/pstl.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/queue.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/ranges.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/regex.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/scoped_allocator.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/set.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/stack.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/string.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/string_view.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/system_error_win_codes.pass.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/unordered_map.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/unordered_set.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/utility.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/diagnostics/vector.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/double_include.gen.py create mode 100644 libcxx/test/libcxx-03/experimental/fexperimental-library.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/extensions/hash/specializations.compile.fail.cpp create mode 100644 libcxx/test/libcxx-03/extensions/hash/specializations.pass.cpp create mode 100644 libcxx/test/libcxx-03/extensions/hash_map/const_iterator.compile.fail.cpp create mode 100644 libcxx/test/libcxx-03/feature_test_macro/ftm_metadata.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/generate_header_test.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/implemented_ftms.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/invalid.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/is_implemented.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/standard_ftms.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/standard_library_headers.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/std_dialects.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/test_data.json create mode 100644 libcxx/test/libcxx-03/feature_test_macro/version_header.sh.py create mode 100644 libcxx/test/libcxx-03/feature_test_macro/version_header_implementation.sh.py create mode 100644 libcxx/test/libcxx-03/fuzzing/format_no_args.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/fuzz.h create mode 100644 libcxx/test/libcxx-03/fuzzing/make_heap.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/nth_element.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/partial_sort.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/partial_sort_copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/partition.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/partition_copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/pop_heap.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/push_heap.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/random.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/regex.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/search.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/sort.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/stable_partition.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/stable_sort.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/unique.pass.cpp create mode 100644 libcxx/test/libcxx-03/fuzzing/unique_copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/gdb/gdb_pretty_printer_test.py create mode 100644 libcxx/test/libcxx-03/gdb/gdb_pretty_printer_test.sh.cpp create mode 100644 libcxx/test/libcxx-03/header_inclusions.gen.py create mode 100644 libcxx/test/libcxx-03/headers_in_modulemap.sh.py create mode 100644 libcxx/test/libcxx-03/include_as_c.sh.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/ifstream.cons/test.dat create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/ifstream.members/test.dat create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/fstreams/traits_mismatch.verify.cpp create mode 100644 libcxx/test/libcxx-03/input.output/file.streams/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/filesystems/class.path/path.member/path.native.obs/string_alloc.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/filesystems/class.path/path.req/is_pathable.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/filesystems/convert_file_time.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/vprint_unicode.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/output.streams/ostream.syn/includes.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/print.fun/transcoding.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/print.fun/vprint_unicode_posix.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.format/print.fun/vprint_unicode_windows.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostream.objects/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/iostreams.base/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/input.output/stream.buffers/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/input.output/string.streams/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp create mode 100644 libcxx/test/libcxx-03/input.output/string.streams/traits_mismatch.verify.cpp create mode 100644 libcxx/test/libcxx-03/iterators/aliasing_iterator.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/assert.advance.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/assert.next.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/assert.prev.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/bounded_iter/arithmetic.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/bounded_iter/comparison.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/bounded_iter/dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/bounded_iter/pointer_traits.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/bounded_iter/types.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/contiguous_iterators.conv.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/contiguous_iterators.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/contiguous_iterators.verify.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.concepts/iterator.concept.random.access/subsumption.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.primitives/iterator.operations/prev.verify.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/locale_dependent.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.concepts/cpp20_iter_concepts.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.concepts/cpp20_iter_traits.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator.requirements/iterator.concepts/integer_like.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/iterator_with_data.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/predef.iterators/counted.iterator/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/get_container.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/predef.iterators/iterators.common/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/predef.iterators/reverse.iterators/bad_template_argument.verify.cpp create mode 100644 libcxx/test/libcxx-03/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp create mode 100644 libcxx/test/libcxx-03/iterators/unwrap_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/language.support/cxa_deleted_virtual.pass.cpp create mode 100644 libcxx/test/libcxx-03/language.support/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.dynamic/assert.nothrow_new_not_overridden_fno_exceptions.pass.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.dynamic/libcpp_deallocate.sh.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.dynamic/new_dont_return_nullptr.pass.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.apple.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp create mode 100644 libcxx/test/libcxx-03/language.support/support.types/cstddef.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/language.support/timespec_get.xopen.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/libcpp_alignof.pass.cpp create mode 100644 libcxx/test/libcxx-03/libcpp_freestanding.sh.cpp create mode 100644 libcxx/test/libcxx-03/libcpp_version.gen.py create mode 100644 libcxx/test/libcxx-03/lint/lint_cmakelists.sh.py create mode 100644 libcxx/test/libcxx-03/lint/lint_headers.sh.py create mode 100644 libcxx/test/libcxx-03/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/localization/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/localization/locale.categories/__scan_keyword.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/locale.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/locale.category.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/no_allocation.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.id/id.pass.cpp create mode 100644 libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp create mode 100644 libcxx/test/libcxx-03/mem/mem.res/nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/memory/aligned_allocation_macro.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/allocator_void.trivial.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/allocator_volatile.verify.cpp create mode 100644 libcxx/test/libcxx-03/memory/is_allocator.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/shared_ptr_array.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/trivial_abi/shared_ptr_arg.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_arg.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_array.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_ret.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/trivial_abi/weak_ptr_ret.pass.cpp create mode 100644 libcxx/test/libcxx-03/memory/uninitialized_allocator_copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/minimal_cxx11_configuration.pass.cpp create mode 100644 libcxx/test/libcxx-03/module_std.gen.py create mode 100644 libcxx/test/libcxx-03/module_std_compat.gen.py create mode 100644 libcxx/test/libcxx-03/no_assert_include.gen.py create mode 100644 libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/c.math/constexpr-cxx23-clang.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/c.math/constexpr-cxx23-gcc.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/c.math/constexpr-fns.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/c.math/fdelayed-template-parsing.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/clamp_to_integral.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/complex.number/__sqr.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/complex.number/cmplx.over.pow.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.gslice.array/assert.get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.gslice.array/get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.indirect.array/assert.get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.indirect.array/get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.mask.array/assert.get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.mask.array/get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.slice.array/assert.get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numarray/class.slice.array/get.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/numeric.ops/midpoint.integer.pass.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.device/has-no-random-device.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.bernoulli/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.bin/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.geo/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.cauchy/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.chisq/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.f/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.lognormal/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.normal/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.t/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.pois/rand.dist.pois.exp/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.pois/rand.dist.pois.extreme/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.pois/rand.dist.pois.gamma/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.pois/rand.dist.pois.poisson/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.pois/rand.dist.pois.weibull/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.pconst/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.plinear/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.uni/rand.dist.uni.int/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.dist/rand.dist.uni/rand.dist.uni.real/bad_engine.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.req.urng/valid_int_type.verify.cpp create mode 100644 libcxx/test/libcxx-03/numerics/rand/rand.req.urng/valid_real_type.verify.cpp create mode 100644 libcxx/test/libcxx-03/odr_signature.exceptions.sh.cpp create mode 100644 libcxx/test/libcxx-03/odr_signature.hardening.sh.cpp create mode 100644 libcxx/test/libcxx-03/ranges/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.access/end.incomplete_type.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.lifetimebound.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.adaptor.helpers/as-lvalue.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.adaptor.helpers/tuple-for-each.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/assert.begin.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/assert.find-next.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/assert.find-prev.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/range.chunk.by.iter/assert.deref.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/range.chunk.by.iter/assert.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.chunk.by/types.h create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.common.view/adaptor.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.counted/adaptor.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.elements/elements_view.no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.elements/sentinel.no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.join/range.join.iterator/ctor.parent.outer.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.join/range.join.iterator/ctor.parent.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.join/range.join.iterator/types.h create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.join/segmented_iterator.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.lazy.split/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.lazy.split/types.h create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/arrow.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/assign.copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/assign.move.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/ctor.default.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/ctor.in_place.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/deref.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/empty_object.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/has_value.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/no_unique_address.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/properties.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.move.wrap/types.h create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.reverse/adaptor.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.split/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.adaptors/range.transform/adaptor.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.factories/range.istream.view/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.factories/range.repeat.view/ctor.piecewise.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.factories/range.repeat.view/ctor.value.bound.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.factories/range.repeat.view/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.factories/range.single.view/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/assign.copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/assign.move.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/constraints.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/ctor.copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/ctor.default.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/ctor.move.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/deref.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/emplace.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/emplace_from.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.nonprop.cache/has_value.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.utility.helpers/different_from.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.utility.helpers/has_arrow.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.utility.helpers/simple_view.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.utility/range.utility.conv/to.internal_constraints.verify.cpp create mode 100644 libcxx/test/libcxx-03/ranges/range.utility/range.utility.conv/to.static_assert.verify.cpp create mode 100644 libcxx/test/libcxx-03/selftest/additional_compile_flags/conditional-compile-flags.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/additional_compile_flags/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/selftest/additional_compile_flags/substitutes-in-compile-flags.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/additional_compile_flags/substitutes-in-run.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.fail.cpp/compile-error.compile.fail.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.fail.cpp/compile-success.compile.fail.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.cpp/compile-error.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.cpp/compile-success.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.cpp/link-error.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.cpp/run-error.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.mm/compile-error.compile.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.mm/compile-success.compile.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.mm/link-error.compile.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/compile.pass.mm/run-error.compile.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/convenience_substitutions/build_run.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/convenience_substitutions/verify.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/dsl/dsl.sh.py create mode 100644 libcxx/test/libcxx-03/selftest/dsl/lit.local.cfg create mode 100644 libcxx/test/libcxx-03/selftest/file_dependencies/a.txt create mode 100644 libcxx/test/libcxx-03/selftest/file_dependencies/absolute-and-relative-paths.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/file_dependencies/dir/b.txt create mode 100644 libcxx/test/libcxx-03/selftest/file_dependencies/substitute-in-dependencies.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/gen.cpp/empty.gen.cpp create mode 100644 libcxx/test/libcxx-03/selftest/gen.cpp/one.gen.cpp create mode 100644 libcxx/test/libcxx-03/selftest/gen.cpp/two.gen.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.fail.cpp/compile-error.link.fail.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.fail.cpp/link-error.link.fail.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.fail.cpp/link-success.link.fail.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.cpp/compile-error.link.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.cpp/link-error.link.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.cpp/link-success.link.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.cpp/run-error.link.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.mm/compile-error.link.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.mm/link-error.link.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.mm/link-success.link.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/link.pass.mm/run-error.link.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/modules/no-modules.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/modules/std-and-std.compat-module.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/modules/std-module.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/modules/std.compat-module.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/pass.cpp/compile-error.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/pass.cpp/link-error.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/pass.cpp/run-error.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/pass.cpp/run-success.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/pass.cpp/werror.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/pass.mm/compile-error.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/pass.mm/link-error.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/pass.mm/no-arc.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/pass.mm/run-error.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/pass.mm/run-success.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/pass.mm/use-objective-cxx.pass.mm create mode 100644 libcxx/test/libcxx-03/selftest/remote-substitutions.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/sh.cpp/run-error.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/sh.cpp/run-success.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/sh.cpp/substitutions.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/sh.cpp/werror.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/shell-no-escape-builtins.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/stdin-is-piped.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/test_macros.pass.cpp create mode 100644 libcxx/test/libcxx-03/selftest/tmpdir-exists.sh.cpp create mode 100644 libcxx/test/libcxx-03/selftest/verify.cpp/no-diagnostics-unmarked.verify.cpp create mode 100644 libcxx/test/libcxx-03/selftest/verify.cpp/no-diagnostics.verify.cpp create mode 100644 libcxx/test/libcxx-03/selftest/verify.cpp/no-werror.verify.cpp create mode 100644 libcxx/test/libcxx-03/selftest/verify.cpp/right-diagnostic.verify.cpp create mode 100644 libcxx/test/libcxx-03/selftest/verify.cpp/wrong-diagnostic.verify.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/alignof.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/nonnull.verify.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/sizeof.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.access/assert.back.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.access/assert.cback.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.access/assert.cfront.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.access/assert.cindex.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.access/assert.front.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.access/assert.index.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.capacity/PR53170.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.capacity/allocation_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.capacity/max_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.cons/copy_shrunk_long.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.cons/debug.iterator.substr.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/assert.iterator.add.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/assert.iterator.decrement.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/assert.iterator.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/assert.iterator.increment.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/assert.iterator.index.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/c.strings/constexpr.cstring.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/c.strings/constexpr.cwchar.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/c.strings/constexpr_memmove.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/string.view/assert.ctor.length.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/string.view/assert.ctor.pointer.pass.cpp create mode 100644 libcxx/test/libcxx-03/strings/string.view/string.view.iterators/assert.iterator-indexing.pass.cpp create mode 100644 libcxx/test/libcxx-03/system_reserved_names.gen.py create mode 100644 libcxx/test/libcxx-03/thread/atomic.availability.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/barrier.availability.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/futures/futures.promise/assert.set_exception.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/futures/futures.task/type.depr.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/futures/futures.task/types.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/latch.availability.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/semaphore.availability.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.barrier/assert.arrive.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.barrier/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.latch/assert.arrive_and_wait.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.latch/assert.count_down.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.latch/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread_safety_lock_guard.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread_safety_missing_unlock.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.mutex/thread_safety_requires_capability.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.semaphore/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.semaphore/assert.release.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.shared_mutex/thread_safety.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.shared_timed_mutex/thread_safety.verify.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.stoptoken/atomic_unique_lock.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.stoptoken/intrusive_list_view.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.stoptoken/intrusive_shared_ptr.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.threads/create_late.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/types.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp create mode 100644 libcxx/test/libcxx-03/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/convert_to_tm.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.gps/time.clock.gps.members/assert.from_utc.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.gps/time.clock.gps.members/assert.to_utc.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.tai/time.clock.tai.members/assert.from_utc.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.tai/time.clock.tai.members/assert.to_utc.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/leap_seconds.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/links.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/rules.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/time.zone.db.list/erase_after.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/time.zone.db.remote/reload_tzdb.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/time.zone.db.tzdb/locate_zone.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/version.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.db/zones.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.info/time.zone.info.local/ostream.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.timezone/choose.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.timezone/time.zone.members/assert.to_local.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys_choose.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp create mode 100644 libcxx/test/libcxx-03/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.rule_selection.pass.cpp create mode 100644 libcxx/test/libcxx-03/transitive_includes.gen.py create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx03.csv create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx11.csv create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx14.csv create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx17.csv create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx20.csv create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx23.csv create mode 100644 libcxx/test/libcxx-03/transitive_includes/cxx26.csv create mode 100755 libcxx/test/libcxx-03/transitive_includes/to_csv.py create mode 100644 libcxx/test/libcxx-03/type_traits/convert_to_integral.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/desugars_to.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_always_bitcastable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_callable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_constant_evaluated.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_implicitly_default_constructible.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_pointer.arc.pass.mm create mode 100644 libcxx/test/libcxx-03/type_traits/is_replaceable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_scalar.objc.pass.mm create mode 100644 libcxx/test/libcxx-03/type_traits/is_specialization.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_specialization.verify.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_trivially_comparable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/is_trivially_relocatable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/lazy_metafunctions.pass.cpp create mode 100644 libcxx/test/libcxx-03/type_traits/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/any/allocator.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/any/size_and_alignment.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/any/small_type.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/assert.exception_guard.no_exceptions.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/exception_guard.no_exceptions.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/exception_guard.odr.sh.cpp create mode 100644 libcxx/test/libcxx-03/utilities/exception_guard.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/and_then.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/assert.arrow.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/assert.deref.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/assert.error.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/error_or.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/noexcept.extension.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/or_else.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/transform_error.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/value.observers.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.expected/value_or.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.unexpected/class.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.unexpected/noexcept.extension.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.unexpected/swap.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/and_then.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/assert.deref.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/assert.error.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/error_or.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/no_unique_address.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/noexcept.extension.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/or_else.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/transform_error.mandates.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/expected.void/value.lwg3940.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/expected/types.h create mode 100644 libcxx/test/libcxx-03/utilities/expol/policies.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/enable_insertable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.arguments/format.arg/arg_t.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.arguments/format.arg/assert.array.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.formatter/format.context/types.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.functions/ascii.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.functions/escaped_output.ascii.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.string/format.string.std/code_point_width_estimation.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.string/format.string.std/concepts_precision.h create mode 100644 libcxx/test/libcxx-03/utilities/format/format.string/format.string.std/escaped_output.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.string/format.string.std/extended_grapheme_cluster.h create mode 100644 libcxx/test/libcxx-03/utilities/format/format.string/format.string.std/extended_grapheme_cluster.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/format/format.string/format.string.std/test_exception.h create mode 100644 libcxx/test/libcxx-03/utilities/format/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.bind.partial/bind_back.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.bind.partial/compose.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.blocks.arc.pass.mm create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.blocks.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.not.fn/not_fn.nttp.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.not.fn/not_fn.nttp.nodiscard.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_7.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke_helpers.h create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/refwrap/binary.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.unary.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/refwrap/unary.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/intseq/for_each_index_sequence.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/is_pointer_in_range.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/is_valid_range.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_funcptr.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_function.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/ptr.align/assume_aligned.const_eval.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/ptr.align/assume_aligned.power2.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/util.smartptr/race_condition.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/util.smartptr/util.smartptr.shared/libcxx.control_block_layout.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.array.zero_size.compile.fail.cpp create mode 100644 libcxx/test/libcxx-03/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.array.zero_size.compile.fail.cpp create mode 100644 libcxx/test/libcxx-03/utilities/meta/is_referenceable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/meta/meta_base.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/meta/stress_tests/stress_test_is_same.sh.cpp create mode 100644 libcxx/test/libcxx-03/utilities/meta/stress_tests/stress_test_metafunctions.sh.cpp create mode 100644 libcxx/test/libcxx-03/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp create mode 100644 libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/block.objc.pass.mm create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional.object.assign/move.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/optional_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/optional/optional.object/triviality.abi.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/smartptr/unique.ptr/null.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/template.bitset/assert.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/template.bitset/includes.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/tuple/__tuple_like.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/tuple/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/tuple/tuple.tuple/empty_member.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/tuple/tuple.tuple/tuple.assign/array.extension.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/__is_inplace_index.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/__is_inplace_type.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/__murmur2_or_cityhash.abi-v1.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/__murmur2_or_cityhash.abi-v2.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/forward/lifetimebound.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/allocate_vocabulary.attributes.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/assert.deallocate.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_piecewise_pair.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_from_underaligned_buffer.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/mem.res.pool/unsynchronized_buffer.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/mem.res/pmr.availability.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/U_V.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivial_copy_move.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivially_copyable.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/assign_tuple_like.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/default.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.tuple_element.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/private_constructor_tag.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/utility/small_buffer.pass.cpp create mode 100644 libcxx/test/libcxx-03/utilities/variant/no_specializations.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/variant/variant.variant/variant.helper/variant_alternative.verify.cpp create mode 100644 libcxx/test/libcxx-03/utilities/variant/variant.variant/variant_size.pass.cpp create mode 100644 libcxx/test/libcxx-03/vendor/apple/availability-with-pedantic-errors.compile.pass.cpp create mode 100644 libcxx/test/libcxx-03/vendor/apple/disable-availability.sh.cpp create mode 100644 libcxx/test/libcxx-03/vendor/apple/system-install-properties.sh.cpp create mode 100644 libcxx/test/libcxx-03/vendor/clang-cl/static-lib-exports.sh.cpp create mode 100644 libcxx/test/libcxx-03/vendor/ibm/bad_function_call.pass.cpp create mode 100644 libcxx/test/libcxx-03/vendor/mingw/static-lib-exports.sh.cpp create mode 100644 libcxx/test/libcxx-03/xopen_source.gen.py diff --git a/libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp b/libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp new file mode 100644 index 0000000000000..aa7a6d98d7d68 --- /dev/null +++ b/libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: target={{.*}}-apple-{{.*}} +// UNSUPPORTED: c++03 + +// This test ensures that libc++ supports being compiled with modules enabled and with +// -Wnon-modular-include-in-module. This effectively checks that we don't include any +// non-modular header from the library. +// +// Since most underlying platforms are not modularized properly, this test currently only +// works on Apple platforms. + +// ADDITIONAL_COMPILE_FLAGS: -Wnon-modular-include-in-module -Wsystem-headers-in-module=std -fmodules -fcxx-modules + +#include diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp new file mode 100644 index 0000000000000..4e51014f20b18 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last, +// RandomNumberGenerator& rand); + +// +// In C++17, random_shuffle has been removed. +// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE +// is defined before including , then random_shuffle will be restored. + +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + +#include +#include +#include + +#include "test_macros.h" + +struct gen +{ + std::ptrdiff_t operator()(std::ptrdiff_t n) + { + return n-1; + } +}; + + +int main(int, char**) +{ + std::vector v; + std::random_shuffle(v.begin(), v.end()); + gen r; + std::random_shuffle(v.begin(), v.end(), r); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp new file mode 100644 index 0000000000000..057f126a93cfe --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last, +// RandomNumberGenerator& rand); + +// UNSUPPORTED: c++03, c++11 + +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE + +#include +#include + +#include "test_macros.h" + +struct gen +{ + std::ptrdiff_t operator()(std::ptrdiff_t n) + { + return n-1; + } +}; + + +void f() { + int v[1] = {1}; + std::random_shuffle(&v[0], &v[1]); // expected-warning {{'random_shuffle' is deprecated}} + gen r; + std::random_shuffle(&v[0], &v[1], r); // expected-warning {{'random_shuffle' is deprecated}} +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp new file mode 100644 index 0000000000000..0c5ae84d97700 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp @@ -0,0 +1,331 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 +// In the modules build, adding another overload of `memmove` doesn't work. +// UNSUPPORTED: clang-modules-build +// GCC complains about "ambiguating" `__builtin_memmove`. +// UNSUPPORTED: gcc + +// + +#include +#include + +// These tests check that `std::copy` and `std::move` (including their variations like `copy_n`) don't forward to +// `std::memmove` when doing so would be observable. + +// This template is a better match than the actual `builtin_memmove` (it can match the pointer type exactly, without an +// implicit conversion to `void*`), so it should hijack the call inside `std::copy` and similar algorithms if it's made. +template +constexpr void* __builtin_memmove(Dst*, Src*, std::size_t) { + assert(false); + return nullptr; +} + +#include +#include +#include +#include +#include +#include + +#include "test_iterators.h" +#include "test_macros.h" + +// S1 and S2 are simple structs that are convertible to each other and have the same bit representation. +struct S1 { + int x; + + constexpr S1() = default; + constexpr S1(int set_x) : x(set_x) {} + + friend constexpr bool operator==(const S1& lhs, const S1& rhs) { return lhs.x == rhs.x; } +}; + +struct S2 { + int x; + + constexpr S2() = default; + constexpr S2(int set_x) : x(set_x) {} + constexpr S2(S1 from) : x(from.x) {} + + friend constexpr bool operator==(const S1& lhs, const S2& rhs) { return lhs.x == rhs.x; } + friend constexpr bool operator==(const S2& lhs, const S2& rhs) { return lhs.x == rhs.x; } +}; + +// U1 and U2 are simple unions that are convertible to each other and have the same bit representation. +union U1 { + int x; + + constexpr U1() = default; + constexpr U1(int set_x) : x(set_x) {} + + friend constexpr bool operator==(const U1& lhs, const U1& rhs) { return lhs.x == rhs.x; } +}; + +union U2 { + int x; + + constexpr U2() = default; + constexpr U2(int set_x) : x(set_x) {} + constexpr U2(U1 from) : x(from.x) {} + + friend constexpr bool operator==(const U1& lhs, const U2& rhs) { return lhs.x == rhs.x; } + friend constexpr bool operator==(const U2& lhs, const U2& rhs) { return lhs.x == rhs.x; } +}; + +struct NonTrivialMoveAssignment { + int i; + + constexpr NonTrivialMoveAssignment() = default; + constexpr NonTrivialMoveAssignment(int set_i) : i(set_i) {} + + constexpr NonTrivialMoveAssignment(NonTrivialMoveAssignment&& rhs) = default; + constexpr NonTrivialMoveAssignment& operator=(NonTrivialMoveAssignment&& rhs) noexcept { + i = rhs.i; + return *this; + } + + constexpr friend bool operator==(const NonTrivialMoveAssignment&, const NonTrivialMoveAssignment&) = default; +}; + +static_assert(!std::is_trivially_move_assignable_v); +static_assert(!std::is_trivially_assignable::value); + +struct NonTrivialMoveCtr { + int i; + + constexpr NonTrivialMoveCtr() = default; + constexpr NonTrivialMoveCtr(int set_i) : i(set_i) {} + + constexpr NonTrivialMoveCtr(NonTrivialMoveCtr&& rhs) noexcept : i(rhs.i) {} + constexpr NonTrivialMoveCtr& operator=(NonTrivialMoveCtr&& rhs) = default; + + constexpr friend bool operator==(const NonTrivialMoveCtr&, const NonTrivialMoveCtr&) = default; +}; + +static_assert(std::is_trivially_move_assignable_v); +static_assert(!std::is_trivially_copyable_v); + +struct NonTrivialCopyAssignment { + int i; + + constexpr NonTrivialCopyAssignment() = default; + constexpr NonTrivialCopyAssignment(int set_i) : i(set_i) {} + + constexpr NonTrivialCopyAssignment(const NonTrivialCopyAssignment& rhs) = default; + constexpr NonTrivialCopyAssignment& operator=(const NonTrivialCopyAssignment& rhs) { + i = rhs.i; + return *this; + } + + constexpr friend bool operator==(const NonTrivialCopyAssignment&, const NonTrivialCopyAssignment&) = default; +}; + +static_assert(!std::is_trivially_copy_assignable_v); + +struct NonTrivialCopyCtr { + int i; + + constexpr NonTrivialCopyCtr() = default; + constexpr NonTrivialCopyCtr(int set_i) : i(set_i) {} + + constexpr NonTrivialCopyCtr(const NonTrivialCopyCtr& rhs) : i(rhs.i) {} + constexpr NonTrivialCopyCtr& operator=(const NonTrivialCopyCtr& rhs) = default; + + constexpr friend bool operator==(const NonTrivialCopyCtr&, const NonTrivialCopyCtr&) = default; +}; + +static_assert(std::is_trivially_copy_assignable_v); +static_assert(!std::is_trivially_copyable_v); + +template +constexpr T make(int from) { + return T(from); +} + +template > +static T make_internal_array[5] = {T(), T(), T(), T(), T()}; + +template +requires std::is_pointer_v +constexpr T make(int i) { + if constexpr (!std::same_as, void>) { + return make_internal_array + i; + } else { + return make_internal_array + i; + } +} + +template class SentWrapper, class OutIter, class Func> +constexpr void test_one(Func func) { + using From = typename std::iterator_traits::value_type; + using To = typename std::iterator_traits::value_type; + + { + const std::size_t N = 5; + + From input[N] = {make(0), make(1), make(2), make(3), make(4)}; + To output[N]; + + auto in = InIter(input); + auto in_end = InIter(input + N); + auto sent = SentWrapper(in_end); + auto out = OutIter(output); + + func(in, sent, out, N); + if constexpr (!std::same_as) { + assert(std::equal(input, input + N, output)); + } else { + bool expected[N] = {false, true, true, true, true}; + assert(std::equal(output, output + N, expected)); + } + } + + { + const std::size_t N = 0; + + From input[1] = {make(1)}; + To output[1] = {make(2)}; + + auto in = InIter(input); + auto in_end = InIter(input + N); + auto sent = SentWrapper(in_end); + auto out = OutIter(output); + + func(in, sent, out, N); + assert(output[0] == make(2)); + } +} + +template class SentWrapper, class OutIter> +constexpr void test_copy() { + // Classic. + if constexpr (std::same_as>) { + test_one([](auto first, auto last, auto out, std::size_t) { + std::copy(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::copy_backward(first, last, out + n); + }); + test_one([](auto first, auto, auto out, std::size_t n) { + std::copy_n(first, n, out); + }); + } + + // Ranges. + test_one([](auto first, auto last, auto out, std::size_t) { + std::ranges::copy(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::ranges::copy_backward(first, last, out + n); + }); + test_one([](auto first, auto, auto out, std::size_t n) { + std::ranges::copy_n(first, n, out); + }); +} + +template class SentWrapper, class OutIter> +constexpr void test_move() { + if constexpr (std::same_as>) { + test_one([](auto first, auto last, auto out, std::size_t) { + std::move(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::move_backward(first, last, out + n); + }); + } + + // Ranges. + test_one([](auto first, auto last, auto out, std::size_t) { + std::ranges::move(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::ranges::move_backward(first, last, out + n); + }); +} + +template +constexpr void test_copy_with_type() { + using FromIter = contiguous_iterator; + using ToIter = contiguous_iterator; + + test_copy(); + test_copy(); + test_copy(); + test_copy(); + test_copy(); +} + +template +constexpr void test_move_with_type() { + using FromIter = contiguous_iterator; + using ToIter = contiguous_iterator; + + test_move(); + test_move(); + test_move(); + test_move(); + test_move(); +} + +template +constexpr void test_copy_and_move() { + test_copy_with_type(); + test_move_with_type(); +} + +template +constexpr void test_both_directions() { + test_copy_and_move(); + if (!std::same_as) { + test_copy_and_move(); + } +} + +constexpr bool test() { + test_copy_with_type(); + test_move_with_type(); + + // Copying from a smaller type into a larger type and vice versa. + test_both_directions(); + test_both_directions(); + + // Copying between types with different representations. + test_both_directions(); + // Copying from `bool` to `char` will invoke the optimization, so only check one direction. + test_copy_and_move(); + + // Copying between different structs with the same representation (there is no way to guarantee the representation is + // the same). + test_copy_and_move(); + // Copying between different unions with the same representation. + test_copy_and_move(); + + // Copying from a regular pointer to a void pointer (these are not considered trivially copyable). + test_copy_and_move(); + // Copying from a non-const pointer to a const pointer (these are not considered trivially copyable). + test_copy_and_move(); + + // `memmove` does not support volatile pointers. + // (See also https://github.com/llvm/llvm-project/issues/28901). + if (!std::is_constant_evaluated()) { + test_both_directions(); + test_both_directions(); + } + + return true; +} + +int main(int, char**) { + test(); + static_assert(test()); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp new file mode 100644 index 0000000000000..ff10c7919200d --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp @@ -0,0 +1,334 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 +// In the modules build, adding another overload of `memmove` doesn't work. +// UNSUPPORTED: clang-modules-build +// GCC complains about "ambiguating" `__builtin_memmove`. +// UNSUPPORTED: gcc + +// + +// These tests check that `std::copy` and `std::move` (including their variations like `copy_n`) forward to +// `memmove` when possible. + +#include + +struct Foo { + int i = 0; + + Foo() = default; + Foo(int set_i) : i(set_i) {} + + friend bool operator==(const Foo&, const Foo&) = default; +}; + +static bool memmove_called = false; + +// This template is a better match than the actual `builtin_memmove` (it can match the pointer type exactly, without an +// implicit conversion to `void*`), so it should hijack the call inside `std::copy` and similar algorithms if it's made. +template +constexpr void* __builtin_memmove(Dst* dst, Src* src, std::size_t count) { + memmove_called = true; + return __builtin_memmove(static_cast(dst), static_cast(src), count); +} + +#include +#include +#include +#include +#include +#include +#include + +#include "test_iterators.h" + +static_assert(std::is_trivially_copyable_v); + +// To test pointers to functions. +void Func() {} +using FuncPtr = decltype(&Func); + +// To test pointers to members. +struct S { + int mem_obj = 0; + void MemFunc() {} +}; +using MemObjPtr = decltype(&S::mem_obj); +using MemFuncPtr = decltype(&S::MemFunc); + +// To test bitfields. +struct BitfieldS { + unsigned char b1 : 3; + unsigned char : 2; + unsigned char b2 : 5; + friend bool operator==(const BitfieldS&, const BitfieldS&) = default; +}; + +// To test non-default alignment. +struct AlignedS { + alignas(64) int x; + alignas(8) int y; + friend bool operator==(const AlignedS&, const AlignedS&) = default; +}; + +template +T make(int from) { + return T(from); +} + +template +requires (std::is_pointer_v && !std::is_function_v>) +T make(int i) { + static std::remove_pointer_t arr[8]; + return arr + i; +} + +template +requires std::same_as +FuncPtr make(int) { + return &Func; +} + +template +requires std::same_as +MemObjPtr make(int) { + return &S::mem_obj; +} + +template +requires std::same_as +MemFuncPtr make(int) { + return &S::MemFunc; +} + +template +requires std::same_as +BitfieldS make(int x) { + BitfieldS result = {}; + result.b1 = x; + result.b2 = x; + return result; +} + +template +requires std::same_as +AlignedS make(int x) { + AlignedS result; + result.x = x; + result.y = x; + return result; +} + +template class SentWrapper, class OutIter, class Func> +void test_one(Func func) { + using From = std::iter_value_t; + using To = std::iter_value_t; + + // Normal case. + { + const std::size_t N = 4; + + From input[N] = {make(1), make(2), make(3), make(4)}; + To output[N]; + + auto in = InIter(input); + auto in_end = InIter(input + N); + auto sent = SentWrapper(in_end); + auto out = OutIter(output); + + assert(!memmove_called); + func(in, sent, out, N); + assert(memmove_called); + memmove_called = false; + + assert(std::equal(input, input + N, output, [](const From& lhs, const To& rhs) { + // Prevents warnings/errors due to mismatched signed-ness. + if constexpr (std::convertible_to) { + return static_cast(lhs) == rhs; + } else if constexpr (std::convertible_to) { + return lhs == static_cast(rhs); + } + })); + } +} + +template class SentWrapper, class OutIter> +void test_copy_and_move() { + // Classic. + if constexpr (std::same_as>) { + test_one([](auto first, auto last, auto out, std::size_t) { + std::copy(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::copy_backward(first, last, out + n); + }); + test_one([](auto first, auto, auto out, std::size_t n) { + std::copy_n(first, n, out); + }); + test_one([](auto first, auto last, auto out, std::size_t) { + std::move(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::move_backward(first, last, out + n); + }); + } + + // Ranges. + test_one([](auto first, auto last, auto out, std::size_t) { + std::ranges::copy(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::ranges::copy_backward(first, last, out + n); + }); + test_one([](auto first, auto, auto out, std::size_t n) { + std::ranges::copy_n(first, n, out); + }); + test_one([](auto first, auto last, auto out, std::size_t) { + std::ranges::move(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::ranges::move_backward(first, last, out + n); + }); +} + +template class SentWrapper, bool BothDirections = !std::same_as> +void test_all_permutations_from_to_sent() { + test_copy_and_move(); + test_copy_and_move, SentWrapper, To*>(); + test_copy_and_move>(); + test_copy_and_move, SentWrapper, contiguous_iterator>(); + + if (BothDirections) { + test_copy_and_move(); + test_copy_and_move, SentWrapper, From*>(); + test_copy_and_move>(); + test_copy_and_move, SentWrapper, contiguous_iterator>(); + } +} + +void test_different_signedness() { + auto check = [](auto alg) { + // Signed -> unsigned. + { + constexpr int N = 3; + constexpr auto min_value = std::numeric_limits::min(); + + int in[N] = {-1, min_value / 2, min_value}; + unsigned int out[N]; + unsigned int expected[N] = { + static_cast(in[0]), + static_cast(in[1]), + static_cast(in[2]), + }; + + assert(!memmove_called); + alg(in, in + N, out, N); + assert(memmove_called); + memmove_called = false; + + assert(std::equal(out, out + N, expected)); + } + + // Unsigned -> signed. + { + constexpr int N = 3; + constexpr auto max_signed = std::numeric_limits::max(); + constexpr auto max_unsigned = std::numeric_limits::max(); + + unsigned int in[N] = {static_cast(max_signed) + 1, max_unsigned / 2, max_unsigned}; + int out[N]; + int expected[N] = { + static_cast(in[0]), + static_cast(in[1]), + static_cast(in[2]), + }; + + assert(!memmove_called); + alg(in, in + N, out, N); + assert(memmove_called); + memmove_called = false; + + assert(std::equal(out, out + N, expected)); + } + }; + + check([](auto first, auto last, auto out, std::size_t) { + std::copy(first, last, out); + }); + check([](auto first, auto last, auto out, std::size_t n) { + std::copy_backward(first, last, out + n); + }); + check([](auto first, auto, auto out, std::size_t n) { + std::copy_n(first, n, out); + }); + check([](auto first, auto last, auto out, std::size_t) { + std::move(first, last, out); + }); + check([](auto first, auto last, auto out, std::size_t n) { + std::move_backward(first, last, out + n); + }); + + // Ranges. + check([](auto first, auto last, auto out, std::size_t) { + std::ranges::copy(first, last, out); + }); + check([](auto first, auto last, auto out, std::size_t n) { + std::ranges::copy_backward(first, last, out + n); + }); + check([](auto first, auto, auto out, std::size_t n) { + std::ranges::copy_n(first, n, out); + }); + check([](auto first, auto last, auto out, std::size_t) { + std::ranges::move(first, last, out); + }); + check([](auto first, auto last, auto out, std::size_t n) { + std::ranges::move_backward(first, last, out + n); + }); +} + +void test() { + // Built-in. + test_all_permutations_from_to_sent(); + // User-defined. + test_all_permutations_from_to_sent(); + + // Conversions. + test_all_permutations_from_to_sent(); + test_all_permutations_from_to_sent(); + // Conversion from `bool` to `char` invokes the optimization (the set of values for `char` is a superset of the set of + // values for `bool`), but the other way round cannot. + test_all_permutations_from_to_sent(); + + // Copying between regular pointers. + test_copy_and_move(); + + // Copying between pointers to functions. + test_copy_and_move(); + + // Copying between pointers to members. + test_copy_and_move(); + test_copy_and_move(); + + // Copying structs with bitfields. + test_copy_and_move(); + + // Copying objects with non-default alignment. + test_copy_and_move(); + + // Copying integers with different signedness produces the same results as built-in assignment. + test_different_signedness(); +} + +int main(int, char**) { + test(); + // The test relies on a global variable, so it cannot be made `constexpr`; the `memmove` optimization is not used in + // `constexpr` mode anyway. + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_unwrap_reverse.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_unwrap_reverse.pass.cpp new file mode 100644 index 0000000000000..2a85e7b5ddcc3 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_unwrap_reverse.pass.cpp @@ -0,0 +1,141 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// + +// These tests checks that `std::copy` and `std::move` (including their variations like `copy_n`) can unwrap multiple +// layers of reverse iterators. + +#include +#include +#include +#include +#include +#include + +#include "test_iterators.h" + +template +requires (N == 0) +constexpr auto wrap_n_times(Iter i) { + return i; +} + +template +requires (N != 0) +constexpr auto wrap_n_times(Iter i) { + return std::make_reverse_iterator(wrap_n_times(i)); +} + +static_assert(std::is_same_v(std::declval())), + std::reverse_iterator>>); + +template class SentWrapper, class OutIter, std::size_t W1, size_t W2, class Func> +constexpr void test_one(Func func) { + using From = std::iter_value_t; + using To = std::iter_value_t; + + const std::size_t N = 4; + + From input[N] = {{1}, {2}, {3}, {4}}; + To output[N]; + + auto in = wrap_n_times(InIter(input)); + auto in_end = wrap_n_times(InIter(input + N)); + auto sent = SentWrapper(in_end); + auto out = wrap_n_times(OutIter(output)); + + func(in, sent, out, N); + + assert(std::equal(input, input + N, output, [](const From& lhs, const To& rhs) { + // Prevents warnings/errors due to mismatched signed-ness. + return lhs == static_cast(rhs); + })); +} + +template class SentWrapper, class OutIter, std::size_t W1, size_t W2> +constexpr void test_copy_and_move() { + // Classic. + if constexpr (std::same_as>) { + test_one([](auto first, auto last, auto out, std::size_t) { + std::copy(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::copy_backward(first, last, out + n); + }); + test_one([](auto first, auto, auto out, std::size_t n) { + std::copy_n(first, n, out); + }); + test_one([](auto first, auto last, auto out, std::size_t) { + std::move(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::move_backward(first, last, out + n); + }); + } + + // Ranges. + test_one([](auto first, auto last, auto out, std::size_t) { + std::ranges::copy(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::ranges::copy_backward(first, last, out + n); + }); + test_one([](auto first, auto, auto out, std::size_t n) { + std::ranges::copy_n(first, n, out); + }); + test_one([](auto first, auto last, auto out, std::size_t) { + std::ranges::move(first, last, out); + }); + test_one([](auto first, auto last, auto out, std::size_t n) { + std::ranges::move_backward(first, last, out + n); + }); +} + +template class SentWrapper> +constexpr void test_all_permutations_with_counts_from_to_sent() { + test_copy_and_move(); + test_copy_and_move, SentWrapper, To*, W1, W2>(); + test_copy_and_move, W1, W2>(); + test_copy_and_move, SentWrapper, contiguous_iterator, W1, W2>(); + + if (!std::same_as) { + test_copy_and_move(); + test_copy_and_move, SentWrapper, From*, W1, W2>(); + test_copy_and_move, W1, W2>(); + test_copy_and_move, SentWrapper, contiguous_iterator, W1, W2>(); + } +} + +template +constexpr void test_all_permutations_with_counts() { + test_all_permutations_with_counts_from_to_sent(); + test_all_permutations_with_counts_from_to_sent(); + test_all_permutations_with_counts_from_to_sent(); + test_all_permutations_with_counts_from_to_sent(); +} + +constexpr bool test() { + test_all_permutations_with_counts<0, 0>(); + test_all_permutations_with_counts<0, 2>(); + test_all_permutations_with_counts<2, 0>(); + test_all_permutations_with_counts<2, 2>(); + test_all_permutations_with_counts<2, 4>(); + test_all_permutations_with_counts<4, 4>(); + + return true; +} + +int main(int, char**) { + test(); + static_assert(test()); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp new file mode 100644 index 0000000000000..cc48a81194e36 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11 + +// + +// template +// void make_heap(Iter first, Iter last); + +#include +#include +#include +#include + +#include "test_macros.h" + +struct Stats { + int compared = 0; + int copied = 0; + int moved = 0; +} stats; + +struct MyInt { + int value; + explicit MyInt(int xval) : value(xval) {} + MyInt(const MyInt& other) : value(other.value) { ++stats.copied; } + MyInt(MyInt&& other) : value(other.value) { ++stats.moved; } + MyInt& operator=(const MyInt& other) { + value = other.value; + ++stats.copied; + return *this; + } + MyInt& operator=(MyInt&& other) { + value = other.value; + ++stats.moved; + return *this; + } + friend bool operator<(const MyInt& a, const MyInt& b) { + ++stats.compared; + return a.value < b.value; + } +}; + +int main(int, char**) +{ + const int N = 100'000; + std::vector v; + v.reserve(N); + std::mt19937 g; + for (int i = 0; i < N; ++i) + v.emplace_back(g()); + + // The exact stats of our current implementation are recorded here. + // If something changes to make them go a bit up or down, that's probably fine, + // and we can just update this test. + // But if they suddenly leap upward, that's a bad thing. + + stats = {}; + std::make_heap(v.begin(), v.end()); + assert(stats.copied == 0); + assert(stats.moved == 153'486); +#if _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_DEBUG + assert(stats.compared == 188'285); +#endif + + assert(std::is_heap(v.begin(), v.end())); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.min.max.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.min.max.pass.cpp new file mode 100644 index 0000000000000..7e765d7e84683 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.min.max.pass.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 +// +//===----------------------------------------------------------------------===// + +// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +#include +#include + +#include "check_assertion.h" + +int main(int, char**) { + std::initializer_list init_list{}; + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::minmax(init_list), + "initializer_list has to contain at least one element"); + + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::minmax(std::array{}), + "range has to contain at least one element"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.oob.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.oob.pass.cpp new file mode 100644 index 0000000000000..6ddee1b2aabe0 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.oob.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// In the debug mode, the comparator validations will notice that it doesn't satisfy strict weak ordering before the +// algorithm actually runs and goes out of bounds, so the test will terminate before the tested assertions are +// triggered. +// UNSUPPORTED: libcpp-hardening-mode=none, libcpp-hardening-mode=debug +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +#include +#include +#include +#include +#include +#include +#include + +#include "bad_comparator_values.h" +#include "check_assertion.h" +#include "invalid_comparator_utilities.h" + +void check_oob_sort_read() { + SortingFixture fixture(SORT_DATA); + + // Check the classic sorting algorithms + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::sort(copy.begin(), copy.end(), fixture.checked_predicate()), + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } + + // Check the Ranges sorting algorithms + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort(copy, fixture.checked_predicate()), + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } +} + +void check_oob_nth_element_read() { + SortingFixture fixture(NTH_ELEMENT_DATA); + + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::nth_element(copy.begin(), copy.begin(), copy.end(), fixture.checked_predicate()), + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } + + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::nth_element(copy, copy.begin(), fixture.checked_predicate()), + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } +} + +int main(int, char**) { + check_oob_sort_read(); + check_oob_nth_element_read(); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.pass.cpp new file mode 100644 index 0000000000000..92671617eb032 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/assert.sort.invalid_comparator.pass.cpp @@ -0,0 +1,195 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// REQUIRES: libcpp-hardening-mode=debug +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +// This test uses a specific combination of an invalid comparator and sequence of values to +// ensure that our sorting functions do not go out-of-bounds and satisfy strict weak ordering in that case. +// Instead, we should fail loud with an assertion. The specific issue we're looking for here is when the comparator +// does not satisfy the strict weak ordering: +// +// Irreflexivity: comp(a, a) is false +// Antisymmetry: comp(a, b) implies that !comp(b, a) +// Transitivity: comp(a, b), comp(b, c) imply comp(a, c) +// Transitivity of equivalence: !comp(a, b), !comp(b, a), !comp(b, c), !comp(c, b) imply !comp(a, c), !comp(c, a) +// +// If this is not satisfied, we have seen issues in the past where the std::sort implementation +// would proceed to do OOB reads. (rdar://106897934). +// Other algorithms like std::stable_sort, std::sort_heap do not go out of bounds but can produce +// incorrect results, we also want to assert on that. +// Sometimes std::sort does not go out of bounds as well, for example, right now if transitivity +// of equivalence is not met, std::sort can only produce incorrect result but would not fail. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bad_comparator_values.h" +#include "check_assertion.h" +#include "invalid_comparator_utilities.h" + +void check_oob_sort_read() { + SortingFixture fixture(SORT_DATA); + + // Check the classic sorting algorithms + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::sort(copy.begin(), copy.end(), fixture.checked_predicate()), + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::stable_sort(copy.begin(), copy.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::make_heap(copy.begin(), copy.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE(std::sort_heap(copy.begin(), copy.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::partial_sort(copy.begin(), copy.end(), copy.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + { + std::vector copy = fixture.create_elements(); + std::vector results(copy.size(), nullptr); + TEST_LIBCPP_ASSERT_FAILURE( + std::partial_sort_copy(copy.begin(), copy.end(), results.begin(), results.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + + // Check the Ranges sorting algorithms + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort(copy, fixture.checked_predicate()), + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::stable_sort(copy, fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::make_heap(copy, fixture.checked_predicate()), "Comparator does not induce a strict weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort_heap(copy, fixture.checked_predicate()), "Comparator does not induce a strict weak ordering"); + } + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::partial_sort(copy, copy.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + { + std::vector copy = fixture.create_elements(); + std::vector results(copy.size(), nullptr); + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::partial_sort_copy(copy, results, fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } +} + +void check_oob_nth_element_read() { + SortingFixture fixture(NTH_ELEMENT_DATA); + + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::nth_element(copy.begin(), copy.begin(), copy.end(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } + + { + std::vector copy = fixture.create_elements(); + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::nth_element(copy, copy.begin(), fixture.checked_predicate()), + "Comparator does not induce a strict weak ordering"); + } +} + +struct FloatContainer { + float value; + bool operator<(const FloatContainer& other) const { return value < other.value; } +}; + +// Nans in floats do not satisfy strict weak ordering by breaking transitivity of equivalence. +std::vector generate_float_data() { + std::vector floats(50); + for (int i = 0; i < 50; ++i) { + floats[i].value = static_cast(i); + } + floats.push_back(FloatContainer{std::numeric_limits::quiet_NaN()}); + std::shuffle(floats.begin(), floats.end(), std::default_random_engine()); + return floats; +} + +void check_nan_floats() { + auto floats = generate_float_data(); + TEST_LIBCPP_ASSERT_FAILURE( + std::sort(floats.begin(), floats.end()), "Your comparator is not a valid strict-weak ordering"); + floats = generate_float_data(); + TEST_LIBCPP_ASSERT_FAILURE( + std::stable_sort(floats.begin(), floats.end()), "Your comparator is not a valid strict-weak ordering"); + floats = generate_float_data(); + std::make_heap(floats.begin(), floats.end()); + TEST_LIBCPP_ASSERT_FAILURE( + std::sort_heap(floats.begin(), floats.end()), "Your comparator is not a valid strict-weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort(generate_float_data(), std::less()), "Your comparator is not a valid strict-weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE(std::ranges::stable_sort(generate_float_data(), std::less()), + "Your comparator is not a valid strict-weak ordering"); + floats = generate_float_data(); + std::ranges::make_heap(floats, std::less()); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort_heap(floats, std::less()), "Your comparator is not a valid strict-weak ordering"); +} + +void check_irreflexive() { + std::vector v(1); + TEST_LIBCPP_ASSERT_FAILURE( + std::sort(v.begin(), v.end(), std::greater_equal()), "Your comparator is not a valid strict-weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE(std::stable_sort(v.begin(), v.end(), std::greater_equal()), + "Your comparator is not a valid strict-weak ordering"); + std::make_heap(v.begin(), v.end(), std::greater_equal()); + TEST_LIBCPP_ASSERT_FAILURE(std::sort_heap(v.begin(), v.end(), std::greater_equal()), + "Comparator does not induce a strict weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort(v, std::greater_equal()), "Your comparator is not a valid strict-weak ordering"); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::stable_sort(v, std::greater_equal()), "Your comparator is not a valid strict-weak ordering"); + std::ranges::make_heap(v, std::greater_equal()); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::sort_heap(v, std::greater_equal()), "Comparator does not induce a strict weak ordering"); +} + +int main(int, char**) { + check_oob_sort_read(); + + check_oob_nth_element_read(); + + check_nan_floats(); + + check_irreflexive(); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/bad_comparator_values.h b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/bad_comparator_values.h new file mode 100644 index 0000000000000..1a5910cfcd937 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/bad_comparator_values.h @@ -0,0 +1,3565 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_LIBCXX_ALGORITHMS_ALG_SORTING_ASSERT_SORT_INVALID_COMPARATOR_BAD_COMPARATOR_VALUES_H +#define TEST_LIBCXX_ALGORITHMS_ALG_SORTING_ASSERT_SORT_INVALID_COMPARATOR_BAD_COMPARATOR_VALUES_H + +#include + +inline constexpr std::string_view NTH_ELEMENT_DATA = R"( +0 0 0 +0 1 0 +0 2 0 +0 3 0 +0 4 1 +0 5 0 +0 6 0 +0 7 0 +1 0 0 +1 1 0 +1 2 0 +1 3 1 +1 4 1 +1 5 1 +1 6 1 +1 7 1 +2 0 1 +2 1 1 +2 2 1 +2 3 1 +2 4 1 +2 5 1 +2 6 1 +2 7 1 +3 0 1 +3 1 1 +3 2 1 +3 3 1 +3 4 1 +3 5 1 +3 6 1 +3 7 1 +4 0 1 +4 1 1 +4 2 1 +4 3 1 +4 4 1 +4 5 1 +4 6 1 +4 7 1 +5 0 1 +5 1 1 +5 2 1 +5 3 1 +5 4 1 +5 5 1 +5 6 1 +5 7 1 +6 0 1 +6 1 1 +6 2 1 +6 3 1 +6 4 1 +6 5 1 +6 6 1 +6 7 1 +7 0 1 +7 1 1 +7 2 1 +7 3 1 +7 4 1 +7 5 1 +7 6 1 +7 7 1 +)"; + +inline constexpr std::string_view SORT_DATA = R"( +0 0 0 +0 1 1 +0 2 1 +0 3 1 +0 4 1 +0 5 1 +0 6 1 +0 7 1 +0 8 1 +0 9 1 +0 10 1 +0 11 1 +0 12 1 +0 13 1 +0 14 1 +0 15 1 +0 16 1 +0 17 1 +0 18 1 +0 19 1 +0 20 1 +0 21 1 +0 22 1 +0 23 1 +0 24 1 +0 25 1 +0 26 1 +0 27 1 +0 28 1 +0 29 1 +0 30 1 +0 31 1 +0 32 1 +0 33 1 +0 34 1 +0 35 1 +0 36 1 +0 37 1 +0 38 1 +0 39 1 +0 40 1 +0 41 1 +0 42 1 +0 43 1 +0 44 1 +0 45 1 +0 46 1 +0 47 1 +0 48 1 +0 49 1 +0 50 1 +0 51 1 +0 52 1 +0 53 1 +0 54 1 +0 55 1 +0 56 1 +0 57 1 +0 58 1 +1 0 0 +1 1 0 +1 2 1 +1 3 1 +1 4 1 +1 5 1 +1 6 1 +1 7 1 +1 8 1 +1 9 1 +1 10 1 +1 11 1 +1 12 1 +1 13 1 +1 14 1 +1 15 1 +1 16 1 +1 17 1 +1 18 1 +1 19 1 +1 20 1 +1 21 1 +1 22 1 +1 23 1 +1 24 1 +1 25 1 +1 26 1 +1 27 1 +1 28 1 +1 29 1 +1 30 1 +1 31 1 +1 32 1 +1 33 1 +1 34 1 +1 35 1 +1 36 1 +1 37 1 +1 38 1 +1 39 1 +1 40 1 +1 41 1 +1 42 1 +1 43 1 +1 44 1 +1 45 1 +1 46 1 +1 47 1 +1 48 1 +1 49 1 +1 50 1 +1 51 1 +1 52 1 +1 53 1 +1 54 1 +1 55 1 +1 56 1 +1 57 1 +1 58 1 +2 0 0 +2 1 0 +2 2 0 +2 3 1 +2 4 1 +2 5 1 +2 6 1 +2 7 1 +2 8 1 +2 9 1 +2 10 1 +2 11 1 +2 12 1 +2 13 1 +2 14 1 +2 15 1 +2 16 1 +2 17 1 +2 18 1 +2 19 1 +2 20 1 +2 21 1 +2 22 1 +2 23 1 +2 24 1 +2 25 1 +2 26 1 +2 27 1 +2 28 1 +2 29 1 +2 30 1 +2 31 1 +2 32 1 +2 33 1 +2 34 1 +2 35 1 +2 36 1 +2 37 1 +2 38 1 +2 39 1 +2 40 1 +2 41 1 +2 42 1 +2 43 1 +2 44 1 +2 45 1 +2 46 1 +2 47 1 +2 48 1 +2 49 1 +2 50 1 +2 51 1 +2 52 1 +2 53 1 +2 54 1 +2 55 1 +2 56 1 +2 57 1 +2 58 1 +3 0 0 +3 1 0 +3 2 0 +3 3 0 +3 4 1 +3 5 1 +3 6 1 +3 7 1 +3 8 1 +3 9 1 +3 10 1 +3 11 1 +3 12 1 +3 13 1 +3 14 1 +3 15 1 +3 16 1 +3 17 1 +3 18 1 +3 19 1 +3 20 1 +3 21 1 +3 22 1 +3 23 1 +3 24 1 +3 25 1 +3 26 1 +3 27 1 +3 28 1 +3 29 1 +3 30 1 +3 31 1 +3 32 1 +3 33 1 +3 34 1 +3 35 1 +3 36 1 +3 37 1 +3 38 1 +3 39 1 +3 40 1 +3 41 1 +3 42 1 +3 43 1 +3 44 1 +3 45 1 +3 46 1 +3 47 1 +3 48 1 +3 49 1 +3 50 1 +3 51 1 +3 52 1 +3 53 1 +3 54 1 +3 55 1 +3 56 1 +3 57 1 +3 58 1 +4 0 0 +4 1 0 +4 2 0 +4 3 0 +4 4 0 +4 5 1 +4 6 1 +4 7 1 +4 8 1 +4 9 1 +4 10 1 +4 11 1 +4 12 1 +4 13 1 +4 14 1 +4 15 1 +4 16 1 +4 17 1 +4 18 1 +4 19 1 +4 20 1 +4 21 1 +4 22 1 +4 23 1 +4 24 1 +4 25 1 +4 26 1 +4 27 1 +4 28 1 +4 29 1 +4 30 1 +4 31 1 +4 32 1 +4 33 1 +4 34 1 +4 35 1 +4 36 1 +4 37 1 +4 38 1 +4 39 1 +4 40 1 +4 41 1 +4 42 1 +4 43 1 +4 44 1 +4 45 1 +4 46 1 +4 47 1 +4 48 1 +4 49 1 +4 50 1 +4 51 1 +4 52 1 +4 53 1 +4 54 1 +4 55 1 +4 56 1 +4 57 1 +4 58 1 +5 0 0 +5 1 0 +5 2 0 +5 3 0 +5 4 0 +5 5 0 +5 6 1 +5 7 1 +5 8 1 +5 9 1 +5 10 1 +5 11 1 +5 12 1 +5 13 1 +5 14 1 +5 15 1 +5 16 1 +5 17 1 +5 18 1 +5 19 1 +5 20 1 +5 21 1 +5 22 1 +5 23 1 +5 24 1 +5 25 1 +5 26 1 +5 27 1 +5 28 1 +5 29 1 +5 30 1 +5 31 1 +5 32 1 +5 33 1 +5 34 1 +5 35 1 +5 36 1 +5 37 1 +5 38 1 +5 39 1 +5 40 1 +5 41 1 +5 42 1 +5 43 1 +5 44 1 +5 45 1 +5 46 1 +5 47 1 +5 48 1 +5 49 1 +5 50 1 +5 51 1 +5 52 1 +5 53 1 +5 54 1 +5 55 1 +5 56 1 +5 57 1 +5 58 1 +6 0 0 +6 1 0 +6 2 0 +6 3 0 +6 4 0 +6 5 0 +6 6 0 +6 7 1 +6 8 1 +6 9 1 +6 10 1 +6 11 1 +6 12 1 +6 13 1 +6 14 1 +6 15 1 +6 16 1 +6 17 1 +6 18 1 +6 19 1 +6 20 1 +6 21 1 +6 22 1 +6 23 1 +6 24 1 +6 25 1 +6 26 1 +6 27 1 +6 28 1 +6 29 1 +6 30 1 +6 31 1 +6 32 1 +6 33 1 +6 34 1 +6 35 1 +6 36 1 +6 37 1 +6 38 1 +6 39 1 +6 40 1 +6 41 1 +6 42 1 +6 43 1 +6 44 1 +6 45 1 +6 46 1 +6 47 1 +6 48 1 +6 49 1 +6 50 1 +6 51 1 +6 52 1 +6 53 1 +6 54 1 +6 55 1 +6 56 1 +6 57 1 +6 58 1 +7 0 0 +7 1 0 +7 2 0 +7 3 0 +7 4 0 +7 5 0 +7 6 0 +7 7 0 +7 8 1 +7 9 1 +7 10 1 +7 11 1 +7 12 1 +7 13 1 +7 14 1 +7 15 1 +7 16 1 +7 17 1 +7 18 1 +7 19 1 +7 20 1 +7 21 1 +7 22 1 +7 23 1 +7 24 1 +7 25 1 +7 26 1 +7 27 1 +7 28 1 +7 29 1 +7 30 1 +7 31 1 +7 32 1 +7 33 1 +7 34 1 +7 35 1 +7 36 1 +7 37 1 +7 38 1 +7 39 1 +7 40 1 +7 41 1 +7 42 1 +7 43 1 +7 44 1 +7 45 1 +7 46 1 +7 47 1 +7 48 1 +7 49 1 +7 50 1 +7 51 1 +7 52 1 +7 53 1 +7 54 1 +7 55 1 +7 56 1 +7 57 1 +7 58 1 +8 0 0 +8 1 0 +8 2 0 +8 3 0 +8 4 0 +8 5 0 +8 6 0 +8 7 0 +8 8 0 +8 9 1 +8 10 1 +8 11 1 +8 12 1 +8 13 1 +8 14 1 +8 15 1 +8 16 1 +8 17 1 +8 18 1 +8 19 1 +8 20 1 +8 21 1 +8 22 1 +8 23 1 +8 24 1 +8 25 1 +8 26 1 +8 27 1 +8 28 1 +8 29 1 +8 30 1 +8 31 1 +8 32 1 +8 33 1 +8 34 1 +8 35 1 +8 36 1 +8 37 1 +8 38 1 +8 39 1 +8 40 1 +8 41 1 +8 42 1 +8 43 1 +8 44 1 +8 45 1 +8 46 1 +8 47 1 +8 48 1 +8 49 1 +8 50 1 +8 51 1 +8 52 1 +8 53 1 +8 54 1 +8 55 1 +8 56 1 +8 57 1 +8 58 1 +9 0 0 +9 1 0 +9 2 0 +9 3 0 +9 4 0 +9 5 0 +9 6 0 +9 7 0 +9 8 0 +9 9 0 +9 10 1 +9 11 1 +9 12 1 +9 13 1 +9 14 1 +9 15 1 +9 16 1 +9 17 1 +9 18 1 +9 19 1 +9 20 1 +9 21 1 +9 22 1 +9 23 1 +9 24 1 +9 25 1 +9 26 1 +9 27 1 +9 28 1 +9 29 1 +9 30 1 +9 31 1 +9 32 1 +9 33 1 +9 34 1 +9 35 1 +9 36 1 +9 37 1 +9 38 1 +9 39 1 +9 40 1 +9 41 1 +9 42 1 +9 43 1 +9 44 1 +9 45 1 +9 46 1 +9 47 1 +9 48 1 +9 49 1 +9 50 1 +9 51 1 +9 52 1 +9 53 1 +9 54 1 +9 55 1 +9 56 1 +9 57 1 +9 58 1 +10 0 0 +10 1 0 +10 2 0 +10 3 0 +10 4 0 +10 5 0 +10 6 0 +10 7 0 +10 8 0 +10 9 0 +10 10 0 +10 11 1 +10 12 1 +10 13 1 +10 14 1 +10 15 1 +10 16 1 +10 17 1 +10 18 1 +10 19 1 +10 20 1 +10 21 1 +10 22 1 +10 23 1 +10 24 1 +10 25 1 +10 26 1 +10 27 1 +10 28 1 +10 29 1 +10 30 1 +10 31 1 +10 32 1 +10 33 1 +10 34 1 +10 35 1 +10 36 1 +10 37 1 +10 38 1 +10 39 1 +10 40 1 +10 41 1 +10 42 1 +10 43 1 +10 44 1 +10 45 1 +10 46 1 +10 47 1 +10 48 1 +10 49 1 +10 50 1 +10 51 1 +10 52 1 +10 53 1 +10 54 1 +10 55 1 +10 56 1 +10 57 1 +10 58 1 +11 0 0 +11 1 0 +11 2 0 +11 3 0 +11 4 0 +11 5 0 +11 6 0 +11 7 0 +11 8 0 +11 9 0 +11 10 0 +11 11 0 +11 12 1 +11 13 1 +11 14 1 +11 15 1 +11 16 1 +11 17 1 +11 18 1 +11 19 1 +11 20 1 +11 21 1 +11 22 1 +11 23 1 +11 24 1 +11 25 1 +11 26 1 +11 27 1 +11 28 1 +11 29 1 +11 30 1 +11 31 1 +11 32 1 +11 33 1 +11 34 1 +11 35 1 +11 36 1 +11 37 1 +11 38 1 +11 39 1 +11 40 1 +11 41 1 +11 42 1 +11 43 1 +11 44 1 +11 45 1 +11 46 1 +11 47 1 +11 48 1 +11 49 1 +11 50 1 +11 51 1 +11 52 1 +11 53 1 +11 54 1 +11 55 1 +11 56 1 +11 57 1 +11 58 1 +12 0 0 +12 1 0 +12 2 0 +12 3 0 +12 4 0 +12 5 0 +12 6 0 +12 7 0 +12 8 0 +12 9 0 +12 10 0 +12 11 0 +12 12 0 +12 13 1 +12 14 1 +12 15 1 +12 16 1 +12 17 1 +12 18 1 +12 19 1 +12 20 1 +12 21 1 +12 22 1 +12 23 1 +12 24 1 +12 25 1 +12 26 1 +12 27 1 +12 28 1 +12 29 1 +12 30 1 +12 31 1 +12 32 1 +12 33 1 +12 34 1 +12 35 1 +12 36 1 +12 37 1 +12 38 1 +12 39 1 +12 40 1 +12 41 1 +12 42 1 +12 43 1 +12 44 1 +12 45 1 +12 46 1 +12 47 1 +12 48 1 +12 49 1 +12 50 1 +12 51 1 +12 52 1 +12 53 1 +12 54 1 +12 55 1 +12 56 1 +12 57 1 +12 58 1 +13 0 0 +13 1 0 +13 2 0 +13 3 0 +13 4 0 +13 5 0 +13 6 0 +13 7 0 +13 8 0 +13 9 0 +13 10 0 +13 11 0 +13 12 0 +13 13 0 +13 14 1 +13 15 1 +13 16 1 +13 17 1 +13 18 1 +13 19 1 +13 20 1 +13 21 1 +13 22 1 +13 23 1 +13 24 1 +13 25 1 +13 26 1 +13 27 1 +13 28 1 +13 29 1 +13 30 1 +13 31 1 +13 32 1 +13 33 1 +13 34 1 +13 35 1 +13 36 1 +13 37 1 +13 38 1 +13 39 1 +13 40 1 +13 41 1 +13 42 1 +13 43 1 +13 44 1 +13 45 1 +13 46 1 +13 47 1 +13 48 1 +13 49 1 +13 50 1 +13 51 1 +13 52 1 +13 53 1 +13 54 1 +13 55 1 +13 56 1 +13 57 1 +13 58 1 +14 0 0 +14 1 0 +14 2 0 +14 3 0 +14 4 0 +14 5 0 +14 6 0 +14 7 0 +14 8 0 +14 9 0 +14 10 0 +14 11 0 +14 12 0 +14 13 0 +14 14 0 +14 15 1 +14 16 1 +14 17 1 +14 18 1 +14 19 1 +14 20 1 +14 21 1 +14 22 1 +14 23 1 +14 24 1 +14 25 1 +14 26 1 +14 27 1 +14 28 1 +14 29 1 +14 30 1 +14 31 1 +14 32 1 +14 33 1 +14 34 1 +14 35 1 +14 36 1 +14 37 1 +14 38 1 +14 39 1 +14 40 1 +14 41 1 +14 42 1 +14 43 1 +14 44 1 +14 45 1 +14 46 1 +14 47 1 +14 48 1 +14 49 1 +14 50 1 +14 51 1 +14 52 1 +14 53 1 +14 54 1 +14 55 1 +14 56 1 +14 57 1 +14 58 1 +15 0 0 +15 1 0 +15 2 0 +15 3 0 +15 4 0 +15 5 0 +15 6 0 +15 7 0 +15 8 0 +15 9 0 +15 10 0 +15 11 0 +15 12 0 +15 13 0 +15 14 0 +15 15 0 +15 16 1 +15 17 1 +15 18 1 +15 19 1 +15 20 1 +15 21 1 +15 22 1 +15 23 1 +15 24 1 +15 25 1 +15 26 1 +15 27 1 +15 28 1 +15 29 1 +15 30 1 +15 31 1 +15 32 1 +15 33 1 +15 34 1 +15 35 1 +15 36 1 +15 37 1 +15 38 1 +15 39 1 +15 40 1 +15 41 1 +15 42 1 +15 43 1 +15 44 1 +15 45 1 +15 46 1 +15 47 1 +15 48 1 +15 49 1 +15 50 1 +15 51 1 +15 52 1 +15 53 1 +15 54 1 +15 55 1 +15 56 1 +15 57 1 +15 58 1 +16 0 0 +16 1 0 +16 2 0 +16 3 0 +16 4 0 +16 5 0 +16 6 0 +16 7 0 +16 8 0 +16 9 0 +16 10 0 +16 11 0 +16 12 0 +16 13 0 +16 14 0 +16 15 0 +16 16 0 +16 17 1 +16 18 1 +16 19 1 +16 20 1 +16 21 1 +16 22 1 +16 23 1 +16 24 1 +16 25 1 +16 26 1 +16 27 1 +16 28 1 +16 29 1 +16 30 1 +16 31 1 +16 32 1 +16 33 1 +16 34 1 +16 35 1 +16 36 1 +16 37 1 +16 38 1 +16 39 1 +16 40 1 +16 41 1 +16 42 1 +16 43 1 +16 44 1 +16 45 1 +16 46 1 +16 47 1 +16 48 1 +16 49 1 +16 50 1 +16 51 1 +16 52 1 +16 53 1 +16 54 1 +16 55 1 +16 56 1 +16 57 1 +16 58 1 +17 0 0 +17 1 0 +17 2 0 +17 3 0 +17 4 0 +17 5 0 +17 6 0 +17 7 0 +17 8 0 +17 9 0 +17 10 0 +17 11 0 +17 12 0 +17 13 0 +17 14 0 +17 15 0 +17 16 0 +17 17 0 +17 18 1 +17 19 1 +17 20 1 +17 21 1 +17 22 1 +17 23 1 +17 24 1 +17 25 1 +17 26 1 +17 27 1 +17 28 1 +17 29 1 +17 30 1 +17 31 1 +17 32 1 +17 33 1 +17 34 1 +17 35 1 +17 36 1 +17 37 1 +17 38 1 +17 39 1 +17 40 1 +17 41 1 +17 42 1 +17 43 1 +17 44 1 +17 45 1 +17 46 1 +17 47 1 +17 48 1 +17 49 1 +17 50 1 +17 51 1 +17 52 1 +17 53 1 +17 54 1 +17 55 1 +17 56 1 +17 57 1 +17 58 1 +18 0 0 +18 1 0 +18 2 0 +18 3 0 +18 4 0 +18 5 0 +18 6 0 +18 7 0 +18 8 0 +18 9 0 +18 10 0 +18 11 0 +18 12 0 +18 13 0 +18 14 0 +18 15 0 +18 16 0 +18 17 0 +18 18 0 +18 19 1 +18 20 1 +18 21 1 +18 22 1 +18 23 1 +18 24 1 +18 25 1 +18 26 1 +18 27 1 +18 28 1 +18 29 1 +18 30 1 +18 31 1 +18 32 1 +18 33 1 +18 34 1 +18 35 1 +18 36 1 +18 37 1 +18 38 1 +18 39 1 +18 40 1 +18 41 1 +18 42 1 +18 43 1 +18 44 1 +18 45 1 +18 46 1 +18 47 1 +18 48 1 +18 49 1 +18 50 1 +18 51 1 +18 52 1 +18 53 1 +18 54 1 +18 55 1 +18 56 1 +18 57 1 +18 58 1 +19 0 0 +19 1 0 +19 2 0 +19 3 0 +19 4 0 +19 5 0 +19 6 0 +19 7 0 +19 8 0 +19 9 0 +19 10 0 +19 11 0 +19 12 0 +19 13 0 +19 14 0 +19 15 0 +19 16 0 +19 17 0 +19 18 0 +19 19 0 +19 20 1 +19 21 1 +19 22 1 +19 23 1 +19 24 1 +19 25 1 +19 26 1 +19 27 1 +19 28 1 +19 29 1 +19 30 1 +19 31 1 +19 32 1 +19 33 1 +19 34 1 +19 35 1 +19 36 1 +19 37 1 +19 38 1 +19 39 1 +19 40 1 +19 41 1 +19 42 1 +19 43 1 +19 44 1 +19 45 1 +19 46 1 +19 47 1 +19 48 1 +19 49 1 +19 50 1 +19 51 1 +19 52 1 +19 53 1 +19 54 1 +19 55 1 +19 56 1 +19 57 1 +19 58 1 +20 0 0 +20 1 0 +20 2 0 +20 3 0 +20 4 0 +20 5 0 +20 6 0 +20 7 0 +20 8 0 +20 9 0 +20 10 0 +20 11 0 +20 12 0 +20 13 0 +20 14 0 +20 15 0 +20 16 0 +20 17 0 +20 18 0 +20 19 0 +20 20 0 +20 21 1 +20 22 1 +20 23 1 +20 24 1 +20 25 1 +20 26 1 +20 27 1 +20 28 1 +20 29 1 +20 30 1 +20 31 1 +20 32 1 +20 33 1 +20 34 1 +20 35 1 +20 36 1 +20 37 1 +20 38 1 +20 39 1 +20 40 1 +20 41 1 +20 42 1 +20 43 1 +20 44 1 +20 45 1 +20 46 1 +20 47 1 +20 48 1 +20 49 1 +20 50 1 +20 51 1 +20 52 1 +20 53 1 +20 54 1 +20 55 1 +20 56 1 +20 57 1 +20 58 1 +21 0 0 +21 1 0 +21 2 0 +21 3 0 +21 4 0 +21 5 0 +21 6 0 +21 7 0 +21 8 0 +21 9 0 +21 10 0 +21 11 0 +21 12 0 +21 13 0 +21 14 0 +21 15 0 +21 16 0 +21 17 0 +21 18 0 +21 19 0 +21 20 0 +21 21 0 +21 22 1 +21 23 1 +21 24 1 +21 25 1 +21 26 1 +21 27 1 +21 28 1 +21 29 1 +21 30 1 +21 31 1 +21 32 1 +21 33 1 +21 34 1 +21 35 1 +21 36 1 +21 37 1 +21 38 1 +21 39 1 +21 40 1 +21 41 1 +21 42 1 +21 43 1 +21 44 1 +21 45 1 +21 46 1 +21 47 1 +21 48 1 +21 49 1 +21 50 1 +21 51 1 +21 52 1 +21 53 1 +21 54 1 +21 55 1 +21 56 1 +21 57 1 +21 58 1 +22 0 0 +22 1 0 +22 2 0 +22 3 0 +22 4 0 +22 5 0 +22 6 0 +22 7 0 +22 8 0 +22 9 0 +22 10 0 +22 11 0 +22 12 0 +22 13 0 +22 14 0 +22 15 0 +22 16 0 +22 17 0 +22 18 0 +22 19 0 +22 20 0 +22 21 0 +22 22 0 +22 23 1 +22 24 1 +22 25 1 +22 26 1 +22 27 1 +22 28 1 +22 29 1 +22 30 1 +22 31 1 +22 32 1 +22 33 1 +22 34 1 +22 35 1 +22 36 1 +22 37 1 +22 38 1 +22 39 1 +22 40 1 +22 41 1 +22 42 1 +22 43 1 +22 44 1 +22 45 1 +22 46 1 +22 47 1 +22 48 1 +22 49 1 +22 50 1 +22 51 1 +22 52 1 +22 53 1 +22 54 1 +22 55 1 +22 56 1 +22 57 1 +22 58 1 +23 0 0 +23 1 0 +23 2 0 +23 3 0 +23 4 0 +23 5 0 +23 6 0 +23 7 0 +23 8 0 +23 9 0 +23 10 0 +23 11 0 +23 12 0 +23 13 0 +23 14 0 +23 15 0 +23 16 0 +23 17 0 +23 18 0 +23 19 0 +23 20 0 +23 21 0 +23 22 0 +23 23 0 +23 24 1 +23 25 1 +23 26 1 +23 27 1 +23 28 1 +23 29 1 +23 30 1 +23 31 1 +23 32 1 +23 33 1 +23 34 1 +23 35 1 +23 36 1 +23 37 1 +23 38 1 +23 39 1 +23 40 1 +23 41 1 +23 42 1 +23 43 1 +23 44 1 +23 45 1 +23 46 1 +23 47 1 +23 48 1 +23 49 1 +23 50 1 +23 51 1 +23 52 1 +23 53 1 +23 54 1 +23 55 1 +23 56 1 +23 57 1 +23 58 1 +24 0 0 +24 1 0 +24 2 0 +24 3 0 +24 4 0 +24 5 0 +24 6 0 +24 7 0 +24 8 0 +24 9 0 +24 10 0 +24 11 0 +24 12 0 +24 13 0 +24 14 0 +24 15 0 +24 16 0 +24 17 0 +24 18 0 +24 19 0 +24 20 0 +24 21 0 +24 22 0 +24 23 0 +24 24 0 +24 25 1 +24 26 1 +24 27 1 +24 28 1 +24 29 1 +24 30 1 +24 31 1 +24 32 1 +24 33 1 +24 34 1 +24 35 1 +24 36 1 +24 37 1 +24 38 1 +24 39 1 +24 40 1 +24 41 1 +24 42 1 +24 43 1 +24 44 1 +24 45 1 +24 46 1 +24 47 1 +24 48 1 +24 49 1 +24 50 1 +24 51 1 +24 52 1 +24 53 1 +24 54 1 +24 55 1 +24 56 1 +24 57 1 +24 58 1 +25 0 0 +25 1 0 +25 2 0 +25 3 0 +25 4 0 +25 5 0 +25 6 0 +25 7 0 +25 8 0 +25 9 0 +25 10 0 +25 11 0 +25 12 0 +25 13 0 +25 14 0 +25 15 0 +25 16 0 +25 17 0 +25 18 0 +25 19 0 +25 20 0 +25 21 0 +25 22 0 +25 23 0 +25 24 0 +25 25 0 +25 26 1 +25 27 1 +25 28 1 +25 29 1 +25 30 1 +25 31 1 +25 32 1 +25 33 1 +25 34 1 +25 35 1 +25 36 1 +25 37 1 +25 38 1 +25 39 1 +25 40 1 +25 41 1 +25 42 1 +25 43 1 +25 44 1 +25 45 1 +25 46 1 +25 47 1 +25 48 1 +25 49 1 +25 50 1 +25 51 1 +25 52 1 +25 53 1 +25 54 1 +25 55 1 +25 56 1 +25 57 1 +25 58 1 +26 0 0 +26 1 0 +26 2 0 +26 3 0 +26 4 0 +26 5 0 +26 6 0 +26 7 0 +26 8 0 +26 9 0 +26 10 0 +26 11 0 +26 12 0 +26 13 0 +26 14 0 +26 15 0 +26 16 0 +26 17 0 +26 18 0 +26 19 0 +26 20 0 +26 21 0 +26 22 0 +26 23 0 +26 24 0 +26 25 0 +26 26 0 +26 27 1 +26 28 1 +26 29 1 +26 30 1 +26 31 1 +26 32 1 +26 33 1 +26 34 1 +26 35 1 +26 36 1 +26 37 1 +26 38 1 +26 39 1 +26 40 1 +26 41 1 +26 42 1 +26 43 1 +26 44 1 +26 45 1 +26 46 1 +26 47 1 +26 48 1 +26 49 1 +26 50 1 +26 51 1 +26 52 1 +26 53 1 +26 54 1 +26 55 1 +26 56 1 +26 57 1 +26 58 1 +27 0 0 +27 1 0 +27 2 0 +27 3 0 +27 4 0 +27 5 0 +27 6 0 +27 7 0 +27 8 0 +27 9 0 +27 10 0 +27 11 0 +27 12 0 +27 13 0 +27 14 0 +27 15 0 +27 16 0 +27 17 0 +27 18 0 +27 19 0 +27 20 0 +27 21 0 +27 22 0 +27 23 0 +27 24 0 +27 25 0 +27 26 0 +27 27 0 +27 28 1 +27 29 1 +27 30 1 +27 31 1 +27 32 1 +27 33 1 +27 34 1 +27 35 1 +27 36 1 +27 37 1 +27 38 1 +27 39 1 +27 40 1 +27 41 1 +27 42 1 +27 43 1 +27 44 1 +27 45 1 +27 46 1 +27 47 1 +27 48 1 +27 49 1 +27 50 1 +27 51 1 +27 52 1 +27 53 1 +27 54 1 +27 55 1 +27 56 1 +27 57 1 +27 58 1 +28 0 0 +28 1 0 +28 2 0 +28 3 0 +28 4 0 +28 5 0 +28 6 0 +28 7 0 +28 8 0 +28 9 0 +28 10 0 +28 11 0 +28 12 0 +28 13 0 +28 14 0 +28 15 0 +28 16 0 +28 17 0 +28 18 0 +28 19 0 +28 20 0 +28 21 0 +28 22 0 +28 23 0 +28 24 0 +28 25 0 +28 26 0 +28 27 0 +28 28 0 +28 29 1 +28 30 0 +28 31 0 +28 32 0 +28 33 0 +28 34 0 +28 35 0 +28 36 0 +28 37 0 +28 38 0 +28 39 0 +28 40 0 +28 41 0 +28 42 0 +28 43 0 +28 44 0 +28 45 0 +28 46 0 +28 47 0 +28 48 0 +28 49 0 +28 50 0 +28 51 0 +28 52 0 +28 53 0 +28 54 0 +28 55 0 +28 56 0 +28 57 0 +28 58 0 +29 0 0 +29 1 0 +29 2 0 +29 3 0 +29 4 0 +29 5 0 +29 6 0 +29 7 0 +29 8 0 +29 9 0 +29 10 0 +29 11 0 +29 12 0 +29 13 0 +29 14 0 +29 15 0 +29 16 0 +29 17 0 +29 18 0 +29 19 0 +29 20 0 +29 21 0 +29 22 0 +29 23 0 +29 24 0 +29 25 0 +29 26 0 +29 27 0 +29 28 1 +29 29 0 +29 30 1 +29 31 0 +29 32 0 +29 33 0 +29 34 0 +29 35 0 +29 36 0 +29 37 0 +29 38 0 +29 39 0 +29 40 0 +29 41 0 +29 42 0 +29 43 0 +29 44 0 +29 45 0 +29 46 0 +29 47 0 +29 48 0 +29 49 0 +29 50 0 +29 51 0 +29 52 0 +29 53 0 +29 54 0 +29 55 0 +29 56 0 +29 57 0 +29 58 0 +30 0 0 +30 1 0 +30 2 0 +30 3 0 +30 4 0 +30 5 0 +30 6 0 +30 7 0 +30 8 0 +30 9 0 +30 10 0 +30 11 0 +30 12 0 +30 13 0 +30 14 0 +30 15 0 +30 16 0 +30 17 0 +30 18 0 +30 19 0 +30 20 0 +30 21 0 +30 22 0 +30 23 0 +30 24 0 +30 25 0 +30 26 0 +30 27 0 +30 28 1 +30 29 1 +30 30 0 +30 31 1 +30 32 0 +30 33 0 +30 34 0 +30 35 0 +30 36 0 +30 37 0 +30 38 0 +30 39 0 +30 40 0 +30 41 0 +30 42 0 +30 43 0 +30 44 0 +30 45 0 +30 46 0 +30 47 0 +30 48 0 +30 49 0 +30 50 0 +30 51 0 +30 52 0 +30 53 0 +30 54 0 +30 55 0 +30 56 0 +30 57 0 +30 58 0 +31 0 0 +31 1 0 +31 2 0 +31 3 0 +31 4 0 +31 5 0 +31 6 0 +31 7 0 +31 8 0 +31 9 0 +31 10 0 +31 11 0 +31 12 0 +31 13 0 +31 14 0 +31 15 0 +31 16 0 +31 17 0 +31 18 0 +31 19 0 +31 20 0 +31 21 0 +31 22 0 +31 23 0 +31 24 0 +31 25 0 +31 26 0 +31 27 0 +31 28 1 +31 29 1 +31 30 1 +31 31 0 +31 32 1 +31 33 0 +31 34 0 +31 35 0 +31 36 0 +31 37 0 +31 38 0 +31 39 0 +31 40 0 +31 41 0 +31 42 0 +31 43 0 +31 44 0 +31 45 0 +31 46 0 +31 47 0 +31 48 0 +31 49 0 +31 50 0 +31 51 0 +31 52 0 +31 53 0 +31 54 0 +31 55 0 +31 56 0 +31 57 0 +31 58 0 +32 0 0 +32 1 0 +32 2 0 +32 3 0 +32 4 0 +32 5 0 +32 6 0 +32 7 0 +32 8 0 +32 9 0 +32 10 0 +32 11 0 +32 12 0 +32 13 0 +32 14 0 +32 15 0 +32 16 0 +32 17 0 +32 18 0 +32 19 0 +32 20 0 +32 21 0 +32 22 0 +32 23 0 +32 24 0 +32 25 0 +32 26 0 +32 27 0 +32 28 1 +32 29 1 +32 30 1 +32 31 1 +32 32 0 +32 33 1 +32 34 0 +32 35 0 +32 36 0 +32 37 0 +32 38 0 +32 39 0 +32 40 0 +32 41 0 +32 42 0 +32 43 0 +32 44 0 +32 45 0 +32 46 0 +32 47 0 +32 48 0 +32 49 0 +32 50 0 +32 51 0 +32 52 0 +32 53 0 +32 54 0 +32 55 0 +32 56 0 +32 57 0 +32 58 0 +33 0 0 +33 1 0 +33 2 0 +33 3 0 +33 4 0 +33 5 0 +33 6 0 +33 7 0 +33 8 0 +33 9 0 +33 10 0 +33 11 0 +33 12 0 +33 13 0 +33 14 0 +33 15 0 +33 16 0 +33 17 0 +33 18 0 +33 19 0 +33 20 0 +33 21 0 +33 22 0 +33 23 0 +33 24 0 +33 25 0 +33 26 0 +33 27 0 +33 28 1 +33 29 1 +33 30 1 +33 31 1 +33 32 1 +33 33 0 +33 34 1 +33 35 0 +33 36 0 +33 37 0 +33 38 0 +33 39 0 +33 40 0 +33 41 0 +33 42 0 +33 43 0 +33 44 0 +33 45 0 +33 46 0 +33 47 0 +33 48 0 +33 49 0 +33 50 0 +33 51 0 +33 52 0 +33 53 0 +33 54 0 +33 55 0 +33 56 0 +33 57 0 +33 58 0 +34 0 0 +34 1 0 +34 2 0 +34 3 0 +34 4 0 +34 5 0 +34 6 0 +34 7 0 +34 8 0 +34 9 0 +34 10 0 +34 11 0 +34 12 0 +34 13 0 +34 14 0 +34 15 0 +34 16 0 +34 17 0 +34 18 0 +34 19 0 +34 20 0 +34 21 0 +34 22 0 +34 23 0 +34 24 0 +34 25 0 +34 26 0 +34 27 0 +34 28 1 +34 29 1 +34 30 1 +34 31 1 +34 32 1 +34 33 1 +34 34 0 +34 35 1 +34 36 0 +34 37 0 +34 38 0 +34 39 0 +34 40 0 +34 41 0 +34 42 0 +34 43 0 +34 44 0 +34 45 0 +34 46 0 +34 47 0 +34 48 0 +34 49 0 +34 50 0 +34 51 0 +34 52 0 +34 53 0 +34 54 0 +34 55 0 +34 56 0 +34 57 0 +34 58 0 +35 0 0 +35 1 0 +35 2 0 +35 3 0 +35 4 0 +35 5 0 +35 6 0 +35 7 0 +35 8 0 +35 9 0 +35 10 0 +35 11 0 +35 12 0 +35 13 0 +35 14 0 +35 15 0 +35 16 0 +35 17 0 +35 18 0 +35 19 0 +35 20 0 +35 21 0 +35 22 0 +35 23 0 +35 24 0 +35 25 0 +35 26 0 +35 27 0 +35 28 1 +35 29 1 +35 30 1 +35 31 1 +35 32 1 +35 33 1 +35 34 1 +35 35 0 +35 36 1 +35 37 0 +35 38 0 +35 39 0 +35 40 0 +35 41 0 +35 42 0 +35 43 0 +35 44 0 +35 45 0 +35 46 0 +35 47 0 +35 48 0 +35 49 0 +35 50 0 +35 51 0 +35 52 0 +35 53 0 +35 54 0 +35 55 0 +35 56 0 +35 57 0 +35 58 0 +36 0 0 +36 1 0 +36 2 0 +36 3 0 +36 4 0 +36 5 0 +36 6 0 +36 7 0 +36 8 0 +36 9 0 +36 10 0 +36 11 0 +36 12 0 +36 13 0 +36 14 0 +36 15 0 +36 16 0 +36 17 0 +36 18 0 +36 19 0 +36 20 0 +36 21 0 +36 22 0 +36 23 0 +36 24 0 +36 25 0 +36 26 0 +36 27 0 +36 28 1 +36 29 1 +36 30 1 +36 31 1 +36 32 1 +36 33 1 +36 34 1 +36 35 1 +36 36 0 +36 37 1 +36 38 0 +36 39 0 +36 40 0 +36 41 0 +36 42 0 +36 43 0 +36 44 0 +36 45 0 +36 46 0 +36 47 0 +36 48 0 +36 49 0 +36 50 0 +36 51 0 +36 52 0 +36 53 0 +36 54 0 +36 55 0 +36 56 0 +36 57 0 +36 58 0 +37 0 0 +37 1 0 +37 2 0 +37 3 0 +37 4 0 +37 5 0 +37 6 0 +37 7 0 +37 8 0 +37 9 0 +37 10 0 +37 11 0 +37 12 0 +37 13 0 +37 14 0 +37 15 0 +37 16 0 +37 17 0 +37 18 0 +37 19 0 +37 20 0 +37 21 0 +37 22 0 +37 23 0 +37 24 0 +37 25 0 +37 26 0 +37 27 0 +37 28 1 +37 29 1 +37 30 1 +37 31 1 +37 32 1 +37 33 1 +37 34 1 +37 35 1 +37 36 1 +37 37 0 +37 38 1 +37 39 0 +37 40 0 +37 41 0 +37 42 0 +37 43 0 +37 44 0 +37 45 0 +37 46 0 +37 47 0 +37 48 0 +37 49 0 +37 50 0 +37 51 0 +37 52 0 +37 53 0 +37 54 0 +37 55 0 +37 56 0 +37 57 0 +37 58 0 +38 0 0 +38 1 0 +38 2 0 +38 3 0 +38 4 0 +38 5 0 +38 6 0 +38 7 0 +38 8 0 +38 9 0 +38 10 0 +38 11 0 +38 12 0 +38 13 0 +38 14 0 +38 15 0 +38 16 0 +38 17 0 +38 18 0 +38 19 0 +38 20 0 +38 21 0 +38 22 0 +38 23 0 +38 24 0 +38 25 0 +38 26 0 +38 27 0 +38 28 1 +38 29 1 +38 30 1 +38 31 1 +38 32 1 +38 33 1 +38 34 1 +38 35 1 +38 36 1 +38 37 1 +38 38 0 +38 39 1 +38 40 0 +38 41 0 +38 42 0 +38 43 0 +38 44 0 +38 45 0 +38 46 0 +38 47 0 +38 48 0 +38 49 0 +38 50 0 +38 51 0 +38 52 0 +38 53 0 +38 54 0 +38 55 0 +38 56 0 +38 57 0 +38 58 0 +39 0 0 +39 1 0 +39 2 0 +39 3 0 +39 4 0 +39 5 0 +39 6 0 +39 7 0 +39 8 0 +39 9 0 +39 10 0 +39 11 0 +39 12 0 +39 13 0 +39 14 0 +39 15 0 +39 16 0 +39 17 0 +39 18 0 +39 19 0 +39 20 0 +39 21 0 +39 22 0 +39 23 0 +39 24 0 +39 25 0 +39 26 0 +39 27 0 +39 28 1 +39 29 1 +39 30 1 +39 31 1 +39 32 1 +39 33 1 +39 34 1 +39 35 1 +39 36 1 +39 37 1 +39 38 1 +39 39 0 +39 40 1 +39 41 0 +39 42 0 +39 43 0 +39 44 0 +39 45 0 +39 46 0 +39 47 0 +39 48 0 +39 49 0 +39 50 0 +39 51 0 +39 52 0 +39 53 0 +39 54 0 +39 55 0 +39 56 0 +39 57 0 +39 58 0 +40 0 0 +40 1 0 +40 2 0 +40 3 0 +40 4 0 +40 5 0 +40 6 0 +40 7 0 +40 8 0 +40 9 0 +40 10 0 +40 11 0 +40 12 0 +40 13 0 +40 14 0 +40 15 0 +40 16 0 +40 17 0 +40 18 0 +40 19 0 +40 20 0 +40 21 0 +40 22 0 +40 23 0 +40 24 0 +40 25 0 +40 26 0 +40 27 0 +40 28 1 +40 29 1 +40 30 1 +40 31 1 +40 32 1 +40 33 1 +40 34 1 +40 35 1 +40 36 1 +40 37 1 +40 38 1 +40 39 1 +40 40 0 +40 41 1 +40 42 0 +40 43 0 +40 44 0 +40 45 0 +40 46 0 +40 47 0 +40 48 0 +40 49 0 +40 50 0 +40 51 0 +40 52 0 +40 53 0 +40 54 0 +40 55 0 +40 56 0 +40 57 0 +40 58 0 +41 0 0 +41 1 0 +41 2 0 +41 3 0 +41 4 0 +41 5 0 +41 6 0 +41 7 0 +41 8 0 +41 9 0 +41 10 0 +41 11 0 +41 12 0 +41 13 0 +41 14 0 +41 15 0 +41 16 0 +41 17 0 +41 18 0 +41 19 0 +41 20 0 +41 21 0 +41 22 0 +41 23 0 +41 24 0 +41 25 0 +41 26 0 +41 27 0 +41 28 1 +41 29 1 +41 30 1 +41 31 1 +41 32 1 +41 33 1 +41 34 1 +41 35 1 +41 36 1 +41 37 1 +41 38 1 +41 39 1 +41 40 1 +41 41 0 +41 42 1 +41 43 0 +41 44 0 +41 45 0 +41 46 0 +41 47 0 +41 48 0 +41 49 0 +41 50 0 +41 51 0 +41 52 0 +41 53 0 +41 54 0 +41 55 0 +41 56 0 +41 57 0 +41 58 0 +42 0 0 +42 1 0 +42 2 0 +42 3 0 +42 4 0 +42 5 0 +42 6 0 +42 7 0 +42 8 0 +42 9 0 +42 10 0 +42 11 0 +42 12 0 +42 13 0 +42 14 0 +42 15 0 +42 16 0 +42 17 0 +42 18 0 +42 19 0 +42 20 0 +42 21 0 +42 22 0 +42 23 0 +42 24 0 +42 25 0 +42 26 0 +42 27 0 +42 28 1 +42 29 1 +42 30 1 +42 31 1 +42 32 1 +42 33 1 +42 34 1 +42 35 1 +42 36 1 +42 37 1 +42 38 1 +42 39 1 +42 40 1 +42 41 1 +42 42 0 +42 43 1 +42 44 0 +42 45 0 +42 46 0 +42 47 0 +42 48 0 +42 49 0 +42 50 0 +42 51 0 +42 52 0 +42 53 0 +42 54 0 +42 55 0 +42 56 0 +42 57 0 +42 58 0 +43 0 0 +43 1 0 +43 2 0 +43 3 0 +43 4 0 +43 5 0 +43 6 0 +43 7 0 +43 8 0 +43 9 0 +43 10 0 +43 11 0 +43 12 0 +43 13 0 +43 14 0 +43 15 0 +43 16 0 +43 17 0 +43 18 0 +43 19 0 +43 20 0 +43 21 0 +43 22 0 +43 23 0 +43 24 0 +43 25 0 +43 26 0 +43 27 0 +43 28 1 +43 29 1 +43 30 1 +43 31 1 +43 32 1 +43 33 1 +43 34 1 +43 35 1 +43 36 1 +43 37 1 +43 38 1 +43 39 1 +43 40 1 +43 41 1 +43 42 1 +43 43 0 +43 44 1 +43 45 0 +43 46 0 +43 47 0 +43 48 0 +43 49 0 +43 50 0 +43 51 0 +43 52 0 +43 53 0 +43 54 0 +43 55 0 +43 56 0 +43 57 0 +43 58 0 +44 0 0 +44 1 0 +44 2 0 +44 3 0 +44 4 0 +44 5 0 +44 6 0 +44 7 0 +44 8 0 +44 9 0 +44 10 0 +44 11 0 +44 12 0 +44 13 0 +44 14 0 +44 15 0 +44 16 0 +44 17 0 +44 18 0 +44 19 0 +44 20 0 +44 21 0 +44 22 0 +44 23 0 +44 24 0 +44 25 0 +44 26 0 +44 27 0 +44 28 1 +44 29 1 +44 30 1 +44 31 1 +44 32 1 +44 33 1 +44 34 1 +44 35 1 +44 36 1 +44 37 1 +44 38 1 +44 39 1 +44 40 1 +44 41 1 +44 42 1 +44 43 1 +44 44 0 +44 45 1 +44 46 0 +44 47 0 +44 48 0 +44 49 0 +44 50 0 +44 51 0 +44 52 0 +44 53 0 +44 54 0 +44 55 0 +44 56 0 +44 57 0 +44 58 0 +45 0 0 +45 1 0 +45 2 0 +45 3 0 +45 4 0 +45 5 0 +45 6 0 +45 7 0 +45 8 0 +45 9 0 +45 10 0 +45 11 0 +45 12 0 +45 13 0 +45 14 0 +45 15 0 +45 16 0 +45 17 0 +45 18 0 +45 19 0 +45 20 0 +45 21 0 +45 22 0 +45 23 0 +45 24 0 +45 25 0 +45 26 0 +45 27 0 +45 28 1 +45 29 1 +45 30 1 +45 31 1 +45 32 1 +45 33 1 +45 34 1 +45 35 1 +45 36 1 +45 37 1 +45 38 1 +45 39 1 +45 40 1 +45 41 1 +45 42 1 +45 43 1 +45 44 1 +45 45 0 +45 46 1 +45 47 0 +45 48 0 +45 49 0 +45 50 0 +45 51 0 +45 52 0 +45 53 0 +45 54 0 +45 55 0 +45 56 0 +45 57 0 +45 58 0 +46 0 0 +46 1 0 +46 2 0 +46 3 0 +46 4 0 +46 5 0 +46 6 0 +46 7 0 +46 8 0 +46 9 0 +46 10 0 +46 11 0 +46 12 0 +46 13 0 +46 14 0 +46 15 0 +46 16 0 +46 17 0 +46 18 0 +46 19 0 +46 20 0 +46 21 0 +46 22 0 +46 23 0 +46 24 0 +46 25 0 +46 26 0 +46 27 0 +46 28 1 +46 29 1 +46 30 1 +46 31 1 +46 32 1 +46 33 1 +46 34 1 +46 35 1 +46 36 1 +46 37 1 +46 38 1 +46 39 1 +46 40 1 +46 41 1 +46 42 1 +46 43 1 +46 44 1 +46 45 1 +46 46 0 +46 47 1 +46 48 0 +46 49 0 +46 50 0 +46 51 0 +46 52 0 +46 53 0 +46 54 0 +46 55 0 +46 56 0 +46 57 0 +46 58 0 +47 0 0 +47 1 0 +47 2 0 +47 3 0 +47 4 0 +47 5 0 +47 6 0 +47 7 0 +47 8 0 +47 9 0 +47 10 0 +47 11 0 +47 12 0 +47 13 0 +47 14 0 +47 15 0 +47 16 0 +47 17 0 +47 18 0 +47 19 0 +47 20 0 +47 21 0 +47 22 0 +47 23 0 +47 24 0 +47 25 0 +47 26 0 +47 27 0 +47 28 1 +47 29 1 +47 30 1 +47 31 1 +47 32 1 +47 33 1 +47 34 1 +47 35 1 +47 36 1 +47 37 1 +47 38 1 +47 39 1 +47 40 1 +47 41 1 +47 42 1 +47 43 1 +47 44 1 +47 45 1 +47 46 1 +47 47 0 +47 48 1 +47 49 0 +47 50 0 +47 51 0 +47 52 0 +47 53 0 +47 54 0 +47 55 0 +47 56 0 +47 57 0 +47 58 0 +48 0 0 +48 1 0 +48 2 0 +48 3 0 +48 4 0 +48 5 0 +48 6 0 +48 7 0 +48 8 0 +48 9 0 +48 10 0 +48 11 0 +48 12 0 +48 13 0 +48 14 0 +48 15 0 +48 16 0 +48 17 0 +48 18 0 +48 19 0 +48 20 0 +48 21 0 +48 22 0 +48 23 0 +48 24 0 +48 25 0 +48 26 0 +48 27 0 +48 28 1 +48 29 1 +48 30 1 +48 31 1 +48 32 1 +48 33 1 +48 34 1 +48 35 1 +48 36 1 +48 37 1 +48 38 1 +48 39 1 +48 40 1 +48 41 1 +48 42 1 +48 43 1 +48 44 1 +48 45 1 +48 46 1 +48 47 1 +48 48 0 +48 49 1 +48 50 0 +48 51 0 +48 52 0 +48 53 0 +48 54 0 +48 55 0 +48 56 0 +48 57 0 +48 58 0 +49 0 0 +49 1 0 +49 2 0 +49 3 0 +49 4 0 +49 5 0 +49 6 0 +49 7 0 +49 8 0 +49 9 0 +49 10 0 +49 11 0 +49 12 0 +49 13 0 +49 14 0 +49 15 0 +49 16 0 +49 17 0 +49 18 0 +49 19 0 +49 20 0 +49 21 0 +49 22 0 +49 23 0 +49 24 0 +49 25 0 +49 26 0 +49 27 0 +49 28 1 +49 29 1 +49 30 1 +49 31 1 +49 32 1 +49 33 1 +49 34 1 +49 35 1 +49 36 1 +49 37 1 +49 38 1 +49 39 1 +49 40 1 +49 41 1 +49 42 1 +49 43 1 +49 44 1 +49 45 1 +49 46 1 +49 47 1 +49 48 1 +49 49 0 +49 50 1 +49 51 0 +49 52 0 +49 53 0 +49 54 0 +49 55 0 +49 56 0 +49 57 0 +49 58 0 +50 0 0 +50 1 0 +50 2 0 +50 3 0 +50 4 0 +50 5 0 +50 6 0 +50 7 0 +50 8 0 +50 9 0 +50 10 0 +50 11 0 +50 12 0 +50 13 0 +50 14 0 +50 15 0 +50 16 0 +50 17 0 +50 18 0 +50 19 0 +50 20 0 +50 21 0 +50 22 0 +50 23 0 +50 24 0 +50 25 0 +50 26 0 +50 27 0 +50 28 1 +50 29 1 +50 30 1 +50 31 1 +50 32 1 +50 33 1 +50 34 1 +50 35 1 +50 36 1 +50 37 1 +50 38 1 +50 39 1 +50 40 1 +50 41 1 +50 42 1 +50 43 1 +50 44 1 +50 45 1 +50 46 1 +50 47 1 +50 48 1 +50 49 1 +50 50 0 +50 51 1 +50 52 0 +50 53 0 +50 54 0 +50 55 0 +50 56 0 +50 57 0 +50 58 0 +51 0 0 +51 1 0 +51 2 0 +51 3 0 +51 4 0 +51 5 0 +51 6 0 +51 7 0 +51 8 0 +51 9 0 +51 10 0 +51 11 0 +51 12 0 +51 13 0 +51 14 0 +51 15 0 +51 16 0 +51 17 0 +51 18 0 +51 19 0 +51 20 0 +51 21 0 +51 22 0 +51 23 0 +51 24 0 +51 25 0 +51 26 0 +51 27 0 +51 28 1 +51 29 1 +51 30 1 +51 31 1 +51 32 1 +51 33 1 +51 34 1 +51 35 1 +51 36 1 +51 37 1 +51 38 1 +51 39 1 +51 40 1 +51 41 1 +51 42 1 +51 43 1 +51 44 1 +51 45 1 +51 46 1 +51 47 1 +51 48 1 +51 49 1 +51 50 1 +51 51 0 +51 52 1 +51 53 0 +51 54 0 +51 55 0 +51 56 0 +51 57 0 +51 58 0 +52 0 0 +52 1 0 +52 2 0 +52 3 0 +52 4 0 +52 5 0 +52 6 0 +52 7 0 +52 8 0 +52 9 0 +52 10 0 +52 11 0 +52 12 0 +52 13 0 +52 14 0 +52 15 0 +52 16 0 +52 17 0 +52 18 0 +52 19 0 +52 20 0 +52 21 0 +52 22 0 +52 23 0 +52 24 0 +52 25 0 +52 26 0 +52 27 0 +52 28 1 +52 29 1 +52 30 1 +52 31 1 +52 32 1 +52 33 1 +52 34 1 +52 35 1 +52 36 1 +52 37 1 +52 38 1 +52 39 1 +52 40 1 +52 41 1 +52 42 1 +52 43 1 +52 44 1 +52 45 1 +52 46 1 +52 47 1 +52 48 1 +52 49 1 +52 50 1 +52 51 1 +52 52 0 +52 53 1 +52 54 0 +52 55 0 +52 56 0 +52 57 0 +52 58 0 +53 0 0 +53 1 0 +53 2 0 +53 3 0 +53 4 0 +53 5 0 +53 6 0 +53 7 0 +53 8 0 +53 9 0 +53 10 0 +53 11 0 +53 12 0 +53 13 0 +53 14 0 +53 15 0 +53 16 0 +53 17 0 +53 18 0 +53 19 0 +53 20 0 +53 21 0 +53 22 0 +53 23 0 +53 24 0 +53 25 0 +53 26 0 +53 27 0 +53 28 1 +53 29 1 +53 30 1 +53 31 1 +53 32 1 +53 33 1 +53 34 1 +53 35 1 +53 36 1 +53 37 1 +53 38 1 +53 39 1 +53 40 1 +53 41 1 +53 42 1 +53 43 1 +53 44 1 +53 45 1 +53 46 1 +53 47 1 +53 48 1 +53 49 1 +53 50 1 +53 51 1 +53 52 1 +53 53 0 +53 54 1 +53 55 0 +53 56 0 +53 57 0 +53 58 0 +54 0 0 +54 1 0 +54 2 0 +54 3 0 +54 4 0 +54 5 0 +54 6 0 +54 7 0 +54 8 0 +54 9 0 +54 10 0 +54 11 0 +54 12 0 +54 13 0 +54 14 0 +54 15 0 +54 16 0 +54 17 0 +54 18 0 +54 19 0 +54 20 0 +54 21 0 +54 22 0 +54 23 0 +54 24 0 +54 25 0 +54 26 0 +54 27 0 +54 28 1 +54 29 1 +54 30 1 +54 31 1 +54 32 1 +54 33 1 +54 34 1 +54 35 1 +54 36 1 +54 37 1 +54 38 1 +54 39 1 +54 40 1 +54 41 1 +54 42 1 +54 43 1 +54 44 1 +54 45 1 +54 46 1 +54 47 1 +54 48 1 +54 49 1 +54 50 1 +54 51 1 +54 52 1 +54 53 1 +54 54 0 +54 55 1 +54 56 0 +54 57 0 +54 58 0 +55 0 0 +55 1 0 +55 2 0 +55 3 0 +55 4 0 +55 5 0 +55 6 0 +55 7 0 +55 8 0 +55 9 0 +55 10 0 +55 11 0 +55 12 0 +55 13 0 +55 14 0 +55 15 0 +55 16 0 +55 17 0 +55 18 0 +55 19 0 +55 20 0 +55 21 0 +55 22 0 +55 23 0 +55 24 0 +55 25 0 +55 26 0 +55 27 0 +55 28 1 +55 29 1 +55 30 1 +55 31 1 +55 32 1 +55 33 1 +55 34 1 +55 35 1 +55 36 1 +55 37 1 +55 38 1 +55 39 1 +55 40 1 +55 41 1 +55 42 1 +55 43 1 +55 44 1 +55 45 1 +55 46 1 +55 47 1 +55 48 1 +55 49 1 +55 50 1 +55 51 1 +55 52 1 +55 53 1 +55 54 1 +55 55 0 +55 56 1 +55 57 0 +55 58 0 +56 0 0 +56 1 0 +56 2 0 +56 3 0 +56 4 0 +56 5 0 +56 6 0 +56 7 0 +56 8 0 +56 9 0 +56 10 0 +56 11 0 +56 12 0 +56 13 0 +56 14 0 +56 15 0 +56 16 0 +56 17 0 +56 18 0 +56 19 0 +56 20 0 +56 21 0 +56 22 0 +56 23 0 +56 24 0 +56 25 0 +56 26 0 +56 27 0 +56 28 1 +56 29 1 +56 30 1 +56 31 1 +56 32 1 +56 33 1 +56 34 1 +56 35 1 +56 36 1 +56 37 1 +56 38 1 +56 39 1 +56 40 1 +56 41 1 +56 42 1 +56 43 1 +56 44 1 +56 45 1 +56 46 1 +56 47 1 +56 48 1 +56 49 1 +56 50 1 +56 51 1 +56 52 1 +56 53 1 +56 54 1 +56 55 1 +56 56 0 +56 57 1 +56 58 0 +57 0 0 +57 1 0 +57 2 0 +57 3 0 +57 4 0 +57 5 0 +57 6 0 +57 7 0 +57 8 0 +57 9 0 +57 10 0 +57 11 0 +57 12 0 +57 13 0 +57 14 0 +57 15 0 +57 16 0 +57 17 0 +57 18 0 +57 19 0 +57 20 0 +57 21 0 +57 22 0 +57 23 0 +57 24 0 +57 25 0 +57 26 0 +57 27 0 +57 28 1 +57 29 1 +57 30 1 +57 31 1 +57 32 1 +57 33 1 +57 34 1 +57 35 1 +57 36 1 +57 37 1 +57 38 1 +57 39 1 +57 40 1 +57 41 1 +57 42 1 +57 43 1 +57 44 1 +57 45 1 +57 46 1 +57 47 1 +57 48 1 +57 49 1 +57 50 1 +57 51 1 +57 52 1 +57 53 1 +57 54 1 +57 55 1 +57 56 1 +57 57 0 +57 58 1 +58 0 0 +58 1 0 +58 2 0 +58 3 0 +58 4 0 +58 5 0 +58 6 0 +58 7 0 +58 8 0 +58 9 0 +58 10 0 +58 11 0 +58 12 0 +58 13 0 +58 14 0 +58 15 0 +58 16 0 +58 17 0 +58 18 0 +58 19 0 +58 20 0 +58 21 0 +58 22 0 +58 23 0 +58 24 0 +58 25 0 +58 26 0 +58 27 0 +58 28 1 +58 29 1 +58 30 1 +58 31 1 +58 32 1 +58 33 1 +58 34 1 +58 35 1 +58 36 1 +58 37 1 +58 38 1 +58 39 1 +58 40 1 +58 41 1 +58 42 1 +58 43 1 +58 44 1 +58 45 1 +58 46 1 +58 47 1 +58 48 1 +58 49 1 +58 50 1 +58 51 1 +58 52 1 +58 53 1 +58 54 1 +58 55 1 +58 56 1 +58 57 1 +58 58 0 +)"; + +#endif // TEST_LIBCXX_ALGORITHMS_ALG_SORTING_ASSERT_SORT_INVALID_COMPARATOR_BAD_COMPARATOR_VALUES_H diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/invalid_comparator_utilities.h b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/invalid_comparator_utilities.h new file mode 100644 index 0000000000000..f5e602577cae2 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/assert.sort.invalid_comparator/invalid_comparator_utilities.h @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_LIBCXX_ALGORITHMS_ALG_SORTING_ASSERT_SORT_INVALID_COMPARATOR_INVALID_COMPARATOR_UTILITIES_H +#define TEST_LIBCXX_ALGORITHMS_ALG_SORTING_ASSERT_SORT_INVALID_COMPARATOR_INVALID_COMPARATOR_UTILITIES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class ComparisonResults { +public: + explicit ComparisonResults(std::string_view data) { + for (auto line : + std::views::split(data, '\n') | std::views::filter([](auto const& line) { return !line.empty(); })) { + auto values = std::views::split(line, ' '); + auto it = values.begin(); + std::size_t left = std::stol(std::string((*it).data(), (*it).size())); + it = std::next(it); + std::size_t right = std::stol(std::string((*it).data(), (*it).size())); + it = std::next(it); + bool result = static_cast(std::stol(std::string((*it).data(), (*it).size()))); + comparison_results[left][right] = result; + } + } + + bool compare(size_t* left, size_t* right) const { + assert(left != nullptr && right != nullptr && "something is wrong with the test"); + assert(comparison_results.contains(*left) && comparison_results.at(*left).contains(*right) && + "malformed input data?"); + return comparison_results.at(*left).at(*right); + } + + size_t size() const { return comparison_results.size(); } + +private: + std::map> + comparison_results; // terrible for performance, but really convenient +}; + +class SortingFixture { +public: + explicit SortingFixture(std::string_view data) : comparison_results_(data) { + for (std::size_t i = 0; i != comparison_results_.size(); ++i) { + elements_.push_back(std::make_unique(i)); + valid_ptrs_.insert(elements_.back().get()); + } + } + + std::vector create_elements() { + std::vector copy; + for (auto const& e : elements_) + copy.push_back(e.get()); + return copy; + } + + auto checked_predicate() { + return [this](size_t* left, size_t* right) { + // If the pointers passed to the comparator are not in the set of pointers we + // set up above, then we're being passed garbage values from the algorithm + // because we're reading OOB. + assert(valid_ptrs_.contains(left)); + assert(valid_ptrs_.contains(right)); + return comparison_results_.compare(left, right); + }; + } + +private: + ComparisonResults comparison_results_; + std::vector> elements_; + std::set valid_ptrs_; +}; + +#endif // TEST_LIBCXX_ALGORITHMS_ALG_SORTING_ASSERT_SORT_INVALID_COMPARATOR_INVALID_COMPARATOR_UTILITIES_H diff --git a/libcxx/test/libcxx-03/algorithms/alg.sorting/pstl.is_partitioned.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.sorting/pstl.is_partitioned.pass.cpp new file mode 100644 index 0000000000000..86647ccfdef8e --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/alg.sorting/pstl.is_partitioned.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14 + +// UNSUPPORTED: libcpp-has-no-incomplete-pstl + +// Make sure that the predicate is called exactly N times in is_partitioned + +#include +#include +#include +#include +#include + +int main(int, char**) { + std::size_t call_count = 0; + int a[] = {1, 2, 3, 4, 5, 6, 7, 8}; + assert(std::is_partitioned(std::execution::seq, std::begin(a), std::end(a), [&](int i) { + ++call_count; + return i < 5; + })); + assert(call_count == std::size(a)); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp b/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp new file mode 100644 index 0000000000000..a0b5b88bb9f0e --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// std::sort + +#include +#include +#include +#include + +struct BadIter { + struct Value { + friend bool operator==(const Value& x, const Value& y); + friend bool operator!=(const Value& x, const Value& y); + friend bool operator< (const Value& x, const Value& y); + friend bool operator<=(const Value& x, const Value& y); + friend bool operator> (const Value& x, const Value& y); + friend bool operator>=(const Value& x, const Value& y); + friend void swap(Value, Value); + }; + + using iterator_category = std::random_access_iterator_tag; + using value_type = Value; + using reference = Value&; + using difference_type = long; + using pointer = Value*; + + Value operator*() const; // Not `Value&`. + reference operator[](difference_type n) const; + + BadIter& operator++(); + BadIter& operator--(); + BadIter operator++(int); + BadIter operator--(int); + + BadIter& operator+=(difference_type n); + BadIter& operator-=(difference_type n); + friend BadIter operator+(BadIter x, difference_type n); + friend BadIter operator+(difference_type n, BadIter x); + friend BadIter operator-(BadIter x, difference_type n); + friend difference_type operator-(BadIter x, BadIter y); + + friend bool operator==(const BadIter& x, const BadIter& y); + friend bool operator!=(const BadIter& x, const BadIter& y); + friend bool operator< (const BadIter& x, const BadIter& y); + friend bool operator<=(const BadIter& x, const BadIter& y); + friend bool operator> (const BadIter& x, const BadIter& y); + friend bool operator>=(const BadIter& x, const BadIter& y); +}; + +// Verify that iterators with incorrect `iterator_traits` are rejected. This protects against potential undefined +// behavior when these iterators are passed to standard algorithms. +void test() { + std::sort(BadIter(), BadIter()); + //expected-error-re@*:* {{static assertion failed {{.*}}It looks like your iterator's `iterator_traits::reference` does not match the return type of dereferencing the iterator}} +} diff --git a/libcxx/test/libcxx-03/algorithms/callable-requirements-rvalue.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/callable-requirements-rvalue.compile.pass.cpp new file mode 100644 index 0000000000000..4a5535e71ab96 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/callable-requirements-rvalue.compile.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// + +// Make sure that we don't error out when passing a comparator that is lvalue callable +// but not rvalue callable to algorithms. While it is technically ill-formed for users +// to provide us such predicates, this test is useful for libc++ to ensure that we check +// predicate requirements correctly (i.e. that we check them on lvalues and not on +// rvalues). See https://github.com/llvm/llvm-project/issues/69554 for additional +// context. + +#include + +#include "test_macros.h" + +struct NotRvalueCallable { + bool operator()(int a, int b) const& { return a < b; } + bool operator()(int, int) && = delete; +}; + +void f() { + int a[] = {1, 2, 3, 4}; + (void)std::lower_bound(a, a + 4, 0, NotRvalueCallable{}); + (void)std::upper_bound(a, a + 4, 0, NotRvalueCallable{}); + (void)std::minmax({1, 2, 3}, NotRvalueCallable{}); + (void)std::minmax_element(a, a + 4, NotRvalueCallable{}); + (void)std::min_element(a, a + 4, NotRvalueCallable{}); + (void)std::max_element(a, a + 4, NotRvalueCallable{}); + (void)std::is_permutation(a, a + 4, a, NotRvalueCallable{}); +#if TEST_STD_VER >= 14 + (void)std::is_permutation(a, a + 4, a, a + 4, NotRvalueCallable{}); +#endif + (void)std::includes(a, a + 4, a, a + 4, NotRvalueCallable{}); + (void)std::equal_range(a, a + 4, 0, NotRvalueCallable{}); + (void)std::partial_sort_copy(a, a + 4, a, a + 4, NotRvalueCallable{}); + (void)std::search(a, a + 4, a, a + 4, NotRvalueCallable{}); + (void)std::search_n(a, a + 4, 4, 0, NotRvalueCallable{}); +} diff --git a/libcxx/test/libcxx-03/algorithms/callable-requirements.verify.cpp b/libcxx/test/libcxx-03/algorithms/callable-requirements.verify.cpp new file mode 100644 index 0000000000000..7555d9815c60b --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/callable-requirements.verify.cpp @@ -0,0 +1,118 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Ignore spurious errors after the initial static_assert failure. +// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error + +// + +// Check that calling a classic STL algorithm with various non-callable comparators is diagnosed. + +#include + +#include "test_macros.h" + +struct NotCallable { + bool compare(int a, int b) const { return a < b; } +}; + +struct NotMutableCallable { + bool operator()(int a, int b) = delete; + bool operator()(int a, int b) const { return a < b; } +}; + +void f() { + int a[] = {1, 2, 3, 4}; + { + (void)std::lower_bound(a, a + 4, 0, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::upper_bound(a, a + 4, 0, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::minmax({1, 2, 3}, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::minmax_element(a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::min_element(a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::max_element(a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::is_permutation(a, a + 4, a, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + +#if TEST_STD_VER >= 14 + (void)std::is_permutation(a, a + 4, a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} +#endif + + (void)std::includes(a, a + 4, a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::equal_range(a, a + 4, 0, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::partial_sort_copy(a, a + 4, a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::search(a, a + 4, a, a + 4, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::search_n(a, a + 4, 4, 0, &NotCallable::compare); + // expected-error@*:* {{The comparator has to be callable}} + } + + { + (void)std::lower_bound(a, a + 4, 0, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::upper_bound(a, a + 4, 0, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::minmax({1, 2, 3}, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::minmax_element(a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::min_element(a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::max_element(a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::is_permutation(a, a + 4, a, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + +#if TEST_STD_VER >= 14 + (void)std::is_permutation(a, a + 4, a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} +#endif + + (void)std::includes(a, a + 4, a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::equal_range(a, a + 4, 0, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::partial_sort_copy(a, a + 4, a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::search(a, a + 4, a, a + 4, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + + (void)std::search_n(a, a + 4, 4, 0, NotMutableCallable{}); + // expected-error@*:* {{The comparator has to be callable}} + } +} diff --git a/libcxx/test/libcxx-03/algorithms/cpp17_iterator_concepts.verify.cpp b/libcxx/test/libcxx-03/algorithms/cpp17_iterator_concepts.verify.cpp new file mode 100644 index 0000000000000..c4462b26f5c92 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/cpp17_iterator_concepts.verify.cpp @@ -0,0 +1,425 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Check that __cpp17_*_iterator catch bad iterators + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +#include <__iterator/cpp17_iterator_concepts.h> +#include <__iterator/iterator_traits.h> +#include +#include + +struct missing_deref { + using difference_type = std::ptrdiff_t; + using iterator_category = std::input_iterator_tag; + using value_type = int; + using reference = int&; + + missing_deref& operator++(); +}; + +struct missing_preincrement { + using difference_type = std::ptrdiff_t; + using iterator_category = std::input_iterator_tag; + using value_type = int; + using reference = int&; + + int& operator*(); +}; + +template +struct valid_iterator { + using difference_type = std::ptrdiff_t; + using iterator_category = std::input_iterator_tag; + using value_type = int; + using reference = int&; + + int& operator*() const; + Derived& operator++(); + + struct Proxy { + int operator*(); + }; + + Proxy operator++(int); +}; + +struct not_move_constructible : valid_iterator { + not_move_constructible(const not_move_constructible&) = default; + not_move_constructible(not_move_constructible&&) = delete; + not_move_constructible& operator=(not_move_constructible&&) = default; + not_move_constructible& operator=(const not_move_constructible&) = default; +}; + +struct not_copy_constructible : valid_iterator { + not_copy_constructible(const not_copy_constructible&) = delete; + not_copy_constructible(not_copy_constructible&&) = default; + not_copy_constructible& operator=(not_copy_constructible&&) = default; + not_copy_constructible& operator=(const not_copy_constructible&) = default; +}; + +struct not_move_assignable : valid_iterator { + not_move_assignable(const not_move_assignable&) = default; + not_move_assignable(not_move_assignable&&) = default; + not_move_assignable& operator=(not_move_assignable&&) = delete; + not_move_assignable& operator=(const not_move_assignable&) = default; +}; + +struct not_copy_assignable : valid_iterator { + not_copy_assignable(const not_copy_assignable&) = default; + not_copy_assignable(not_copy_assignable&&) = default; + not_copy_assignable& operator=(not_copy_assignable&&) = default; + not_copy_assignable& operator=(const not_copy_assignable&) = delete; +}; + +struct diff_t_not_signed : valid_iterator { + using difference_type = unsigned; +}; + +void check_iterator_requirements() { + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expected-note@*:* {{indirection requires pointer operand}} + + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expected-note@*:* {{cannot increment value of type 'missing_preincrement'}} + + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'not_move_constructible' does not satisfy '__cpp17_move_constructible'}} + + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'not_copy_constructible' does not satisfy '__cpp17_copy_constructible'}} + + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'not_move_assignable' does not satisfy '__cpp17_copy_assignable'}} + + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expectted-note@*:* {{because 'not_copy_assignable' does not satisfy '__cpp17_copy_assignable'}} + + static_assert(std::__cpp17_iterator); // expected-error {{static assertion failed}} + // expectted-note@*:* {{'is_signed_v<__iter_diff_t >' evaluated to false}} +} + +struct not_equality_comparable : valid_iterator {}; +bool operator==(not_equality_comparable, not_equality_comparable) = delete; +bool operator!=(not_equality_comparable, not_equality_comparable); + +struct not_unequality_comparable : valid_iterator {}; +bool operator==(not_unequality_comparable, not_unequality_comparable); +bool operator!=(not_unequality_comparable, not_unequality_comparable) = delete; + +void check_input_iterator_requirements() { + // clang-format off + _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(not_equality_comparable, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{'__lhs == __rhs' would be invalid: overload resolution selected deleted operator '=='}} + + _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(not_unequality_comparable, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{'__lhs != __rhs' would be invalid: overload resolution selected deleted operator '!='}} + // clang-format on +} + +template +struct valid_forward_iterator : valid_iterator { + Derived& operator++(); + Derived operator++(int); + + friend bool operator==(Derived, Derived); +}; + +struct not_default_constructible : valid_forward_iterator { + not_default_constructible() = delete; +}; + +struct postincrement_not_ref : valid_iterator {}; +bool operator==(postincrement_not_ref, postincrement_not_ref); + +void check_forward_iterator_requirements() { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(not_default_constructible, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'not_default_constructible' does not satisfy '__cpp17_default_constructible'}} + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(postincrement_not_ref, ""); // expected-error {{static assertion failed}} +#ifndef _AIX + // expected-note-re@*:* {{because type constraint 'convertible_to<{{(valid_iterator::)?}}Proxy, const postincrement_not_ref &>' was not satisfied}} +#endif +} + +struct missing_predecrement : valid_forward_iterator { + missing_deref operator--(int); +}; + +struct missing_postdecrement : valid_forward_iterator { + missing_postdecrement& operator--(); +}; + +struct not_returning_iter_reference : valid_forward_iterator { + struct Proxy { + operator const not_returning_iter_reference&(); + + int operator*(); + }; + + not_returning_iter_reference& operator--(); + Proxy operator--(int); +}; + +void check_bidirectional_iterator_requirements() { + // clang-format off + _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(missing_predecrement, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{cannot decrement value of type 'missing_predecrement'}} + _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(missing_postdecrement, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{cannot decrement value of type 'missing_postdecrement'}} + _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(not_returning_iter_reference, ""); // expected-error {{static assertion failed}} + // expected-note-re@*:* {{because type constraint 'same_as{{ ?}}>' was not satisfied}} + // clang-format on +} + +template +struct valid_random_access_iterator : valid_forward_iterator { + using difference_type = typename valid_forward_iterator::difference_type; + + Derived& operator--(); + Derived operator--(int); + + Derived& operator+=(difference_type); + Derived& operator-=(difference_type); + + friend Derived operator+(valid_random_access_iterator, difference_type); + friend Derived operator+(difference_type, valid_random_access_iterator); + friend Derived operator-(valid_random_access_iterator, difference_type); + friend Derived operator-(difference_type, valid_random_access_iterator); + friend difference_type operator-(valid_random_access_iterator, valid_random_access_iterator); + + int& operator[](difference_type) const; + + friend std::strong_ordering operator<=>(Derived, Derived); +}; + +struct missing_plus_equals : valid_random_access_iterator { + void operator+=(difference_type) = delete; +}; + +struct missing_minus_equals : valid_random_access_iterator { + void operator-=(difference_type) = delete; +}; + +struct missing_plus_iter_diff : valid_random_access_iterator { + void operator+(difference_type) = delete; +}; + +struct missing_plus_diff_iter : valid_random_access_iterator { + friend missing_plus_diff_iter operator+(difference_type, missing_plus_diff_iter) = delete; +}; + +struct missing_plus_iter_diff_const_mut : valid_random_access_iterator { + friend missing_plus_iter_diff_const_mut operator+(missing_plus_iter_diff_const_mut&, difference_type); + friend missing_plus_iter_diff_const_mut operator+(const missing_plus_iter_diff_const_mut&, difference_type) = delete; +}; + +struct missing_plus_iter_diff_mut_const : valid_random_access_iterator { + friend missing_plus_iter_diff_mut_const operator+(missing_plus_iter_diff_mut_const, difference_type); + friend missing_plus_iter_diff_mut_const operator+(difference_type, missing_plus_iter_diff_mut_const&); + friend missing_plus_iter_diff_mut_const operator+(difference_type, const missing_plus_iter_diff_mut_const&) = delete; +}; + +struct missing_minus_iter_diff_const : valid_random_access_iterator { + friend missing_minus_iter_diff_const operator-(missing_minus_iter_diff_const&, difference_type); + friend missing_minus_iter_diff_const operator-(const missing_minus_iter_diff_const&, difference_type) = delete; +}; + +struct missing_minus_iter_iter : valid_random_access_iterator { + friend missing_minus_iter_iter operator-(missing_minus_iter_iter, missing_minus_iter_iter) = delete; +}; + +struct missing_minus_const_iter_iter : valid_random_access_iterator { + friend difference_type operator-(missing_minus_const_iter_iter&, missing_minus_const_iter_iter); + friend difference_type operator-(const missing_minus_const_iter_iter&, missing_minus_const_iter_iter) = delete; +}; + +struct missing_minus_iter_const_iter : valid_random_access_iterator { + friend difference_type operator-(missing_minus_iter_const_iter, missing_minus_iter_const_iter&); + friend difference_type operator-(missing_minus_iter_const_iter, const missing_minus_iter_const_iter&) = delete; +}; + +struct missing_minus_const_iter_const_iter : valid_random_access_iterator { + friend difference_type operator-(missing_minus_const_iter_const_iter&, missing_minus_const_iter_const_iter&); + friend difference_type operator-(const missing_minus_const_iter_const_iter&, missing_minus_const_iter_const_iter&); + friend difference_type operator-(missing_minus_const_iter_const_iter&, const missing_minus_const_iter_const_iter&); + friend difference_type + operator-(const missing_minus_const_iter_const_iter&, const missing_minus_const_iter_const_iter&) = delete; +}; + +struct missing_subscript_operator : valid_random_access_iterator { + int& operator[](difference_type) = delete; +}; + +struct missing_const_subscript_operator : valid_random_access_iterator { + int& operator[](difference_type); + int& operator[](difference_type) const = delete; +}; + +struct missing_less : valid_random_access_iterator { + friend bool operator<(missing_less, missing_less) = delete; +}; + +struct missing_const_mut_less : valid_random_access_iterator { + friend bool operator<(missing_const_mut_less&, missing_const_mut_less&); + friend bool operator<(missing_const_mut_less&, const missing_const_mut_less&); + friend bool operator<(const missing_const_mut_less&, missing_const_mut_less&) = delete; + friend bool operator<(const missing_const_mut_less&, const missing_const_mut_less&); +}; + +struct missing_mut_const_less : valid_random_access_iterator { + friend bool operator<(missing_mut_const_less&, missing_mut_const_less&); + friend bool operator<(missing_mut_const_less&, const missing_mut_const_less&) = delete; + friend bool operator<(const missing_mut_const_less&, missing_mut_const_less&); + friend bool operator<(const missing_mut_const_less&, const missing_mut_const_less&); +}; + +struct missing_const_const_less : valid_random_access_iterator { + friend bool operator<(missing_const_const_less&, missing_const_const_less&); + friend bool operator<(missing_const_const_less&, const missing_const_const_less&); + friend bool operator<(const missing_const_const_less&, missing_const_const_less&); + friend bool operator<(const missing_const_const_less&, const missing_const_const_less&) = delete; +}; + +struct missing_greater : valid_random_access_iterator { + friend bool operator>(missing_greater, missing_greater) = delete; +}; + +struct missing_const_mut_greater : valid_random_access_iterator { + friend bool operator>(missing_const_mut_greater&, missing_const_mut_greater&); + friend bool operator>(missing_const_mut_greater&, const missing_const_mut_greater&); + friend bool operator>(const missing_const_mut_greater&, missing_const_mut_greater&) = delete; + friend bool operator>(const missing_const_mut_greater&, const missing_const_mut_greater&); +}; + +struct missing_mut_const_greater : valid_random_access_iterator { + friend bool operator>(missing_mut_const_greater&, missing_mut_const_greater&); + friend bool operator>(missing_mut_const_greater&, const missing_mut_const_greater&) = delete; + friend bool operator>(const missing_mut_const_greater&, missing_mut_const_greater&); + friend bool operator>(const missing_mut_const_greater&, const missing_mut_const_greater&); +}; + +struct missing_const_const_greater : valid_random_access_iterator { + friend bool operator>(missing_const_const_greater&, missing_const_const_greater&); + friend bool operator>(missing_const_const_greater&, const missing_const_const_greater&); + friend bool operator>(const missing_const_const_greater&, missing_const_const_greater&); + friend bool operator>(const missing_const_const_greater&, const missing_const_const_greater&) = delete; +}; + +struct missing_less_eq : valid_random_access_iterator { + friend bool operator<=(missing_less_eq, missing_less_eq) = delete; +}; + +struct missing_const_mut_less_eq : valid_random_access_iterator { + friend bool operator<=(missing_const_mut_less_eq&, missing_const_mut_less_eq&); + friend bool operator<=(missing_const_mut_less_eq&, const missing_const_mut_less_eq&); + friend bool operator<=(const missing_const_mut_less_eq&, missing_const_mut_less_eq&) = delete; + friend bool operator<=(const missing_const_mut_less_eq&, const missing_const_mut_less_eq&); +}; + +struct missing_mut_const_less_eq : valid_random_access_iterator { + friend bool operator<=(missing_mut_const_less_eq&, missing_mut_const_less_eq&); + friend bool operator<=(missing_mut_const_less_eq&, const missing_mut_const_less_eq&) = delete; + friend bool operator<=(const missing_mut_const_less_eq&, missing_mut_const_less_eq&); + friend bool operator<=(const missing_mut_const_less_eq&, const missing_mut_const_less_eq&); +}; + +struct missing_const_const_less_eq : valid_random_access_iterator { + friend bool operator<=(missing_const_const_less_eq&, missing_const_const_less_eq&); + friend bool operator<=(missing_const_const_less_eq&, const missing_const_const_less_eq&); + friend bool operator<=(const missing_const_const_less_eq&, missing_const_const_less_eq&); + friend bool operator<=(const missing_const_const_less_eq&, const missing_const_const_less_eq&) = delete; +}; + +struct missing_greater_eq : valid_random_access_iterator { + friend bool operator>=(missing_greater_eq, missing_greater_eq) = delete; +}; + +struct missing_const_mut_greater_eq : valid_random_access_iterator { + friend bool operator>=(missing_const_mut_greater_eq&, missing_const_mut_greater_eq&); + friend bool operator>=(missing_const_mut_greater_eq&, const missing_const_mut_greater_eq&); + friend bool operator>=(const missing_const_mut_greater_eq&, missing_const_mut_greater_eq&) = delete; + friend bool operator>=(const missing_const_mut_greater_eq&, const missing_const_mut_greater_eq&); +}; + +struct missing_mut_const_greater_eq : valid_random_access_iterator { + friend bool operator>=(missing_mut_const_greater_eq&, missing_mut_const_greater_eq&); + friend bool operator>=(missing_mut_const_greater_eq&, const missing_mut_const_greater_eq&) = delete; + friend bool operator>=(const missing_mut_const_greater_eq&, missing_mut_const_greater_eq&); + friend bool operator>=(const missing_mut_const_greater_eq&, const missing_mut_const_greater_eq&); +}; + +struct missing_const_const_greater_eq : valid_random_access_iterator { + friend bool operator>=(missing_const_const_greater_eq&, missing_const_const_greater_eq&); + friend bool operator>=(missing_const_const_greater_eq&, const missing_const_const_greater_eq&); + friend bool operator>=(const missing_const_const_greater_eq&, missing_const_const_greater_eq&); + friend bool operator>=(const missing_const_const_greater_eq&, const missing_const_const_greater_eq&) = delete; +}; + +void check_random_access_iterator() { + // clang-format off + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_plus_equals, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter += __n' would be invalid: overload resolution selected deleted operator '+='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_minus_equals, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter -= __n' would be invalid: overload resolution selected deleted operator '-='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_plus_iter_diff, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter + __n' would be invalid: overload resolution selected deleted operator '+'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_plus_diff_iter, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__n + __iter' would be invalid: overload resolution selected deleted operator '+'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_plus_iter_diff_const_mut, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) + __n' would be invalid: overload resolution selected deleted operator '+'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_plus_iter_diff_mut_const, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__n + std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '+'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_minus_iter_diff_const, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) - __n' would be invalid: overload resolution selected deleted operator '-'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_minus_iter_iter, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter - __iter' would be invalid: overload resolution selected deleted operator '-'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_minus_const_iter_iter, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) - __iter' would be invalid: overload resolution selected deleted operator '-'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_minus_iter_const_iter, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter - std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '-'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_minus_const_iter_const_iter, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) - std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '-'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_subscript_operator, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter[__n]' would be invalid: overload resolution selected deleted operator '[]'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_subscript_operator, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter)[__n]' would be invalid: overload resolution selected deleted operator '[]'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_less, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter < __iter' would be invalid: overload resolution selected deleted operator '<'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_mut_less, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) < __iter' would be invalid: overload resolution selected deleted operator '<'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_mut_const_less, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter < std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '<'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_const_less, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) < std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '<'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_greater, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter > __iter' would be invalid: overload resolution selected deleted operator '>'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_mut_greater, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) > __iter' would be invalid: overload resolution selected deleted operator '>'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_mut_const_greater, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter > std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '>'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_const_greater, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) > std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '>'}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_less_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter <= __iter' would be invalid: overload resolution selected deleted operator '<='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_mut_less_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) <= __iter' would be invalid: overload resolution selected deleted operator '<='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_mut_const_less_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter <= std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '<='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_const_less_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) <= std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '<='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_greater_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter >= __iter' would be invalid: overload resolution selected deleted operator '>='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_mut_greater_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) >= __iter' would be invalid: overload resolution selected deleted operator '>='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_mut_const_greater_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because '__iter >= std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '>='}} + _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(missing_const_const_greater_eq, ""); // expected-error {{static assertion failed}} + // expected-note@*:* {{because 'std::as_const(__iter) >= std::as_const(__iter)' would be invalid: overload resolution selected deleted operator '>='}} + // clang-format on +} diff --git a/libcxx/test/libcxx-03/algorithms/debug_less.inconsistent.pass.cpp b/libcxx/test/libcxx-03/algorithms/debug_less.inconsistent.pass.cpp new file mode 100644 index 0000000000000..701edd1335afa --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/debug_less.inconsistent.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// template struct __debug_less + +// Make sure __debug_less asserts when the comparator is not consistent. + +// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug +// UNSUPPORTED: c++03 + +#include +#include + +#include "check_assertion.h" + +template +struct MyType { + int value; + explicit MyType(int xvalue = 0) : value(xvalue) {} +}; + +template +bool operator<(MyType const& LHS, MyType const& RHS) { + return LHS.value < RHS.value; +} + +template +struct BadComparator { + bool operator()(ValueType const&, ValueType const&) const { + return true; + } +}; + +int main(int, char**) { + typedef MyType<0> MT0; + MT0 one(1); + MT0 two(2); + + BadComparator c; + std::__debug_less> d(c); + + TEST_LIBCPP_ASSERT_FAILURE(d(one, two), "Comparator does not induce a strict weak ordering"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx-03/algorithms/debug_less.pass.cpp new file mode 100644 index 0000000000000..4889f94d170a1 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/debug_less.pass.cpp @@ -0,0 +1,260 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// template struct __debug_less + +// __debug_less checks that a comparator actually provides a strict-weak ordering. + +// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug +// UNSUPPORTED: c++03 + +#include +#include +#include +#include + +#include "test_macros.h" +#include "check_assertion.h" + +template +struct MyType { + int value; + explicit MyType(int xvalue = 0) : value(xvalue) {} +}; + +template +bool operator<(MyType const& LHS, MyType const& RHS) { + return LHS.value < RHS.value; +} + +struct CompareBase { + static int called; + static void reset() { + called = 0; + } +}; + +int CompareBase::called = 0; + +template +struct GoodComparator : public CompareBase { + bool operator()(ValueType const& lhs, ValueType const& rhs) const { + ++CompareBase::called; + return lhs < rhs; + } +}; + +template +struct TwoWayHomoComparator : public CompareBase { + bool operator()(T1 const& lhs, T2 const& rhs) const { + ++CompareBase::called; + return lhs < rhs; + } + + bool operator()(T2 const& lhs, T1 const& rhs) const { + ++CompareBase::called; + return lhs < rhs; + } +}; + +template +struct OneWayHomoComparator : public CompareBase { + bool operator()(T1 const& lhs, T2 const& rhs) const { + ++CompareBase::called; + return lhs < rhs; + } +}; + +using std::__debug_less; + +typedef MyType<0> MT0; +typedef MyType<1> MT1; + +void test_passing() { + int& called = CompareBase::called; + called = 0; + MT0 one(1); + MT0 two(2); + MT1 three(3); + MT1 four(4); + + { + typedef GoodComparator C; + typedef __debug_less D; + + C c; + D d(c); + + assert(d(one, two) == true); + assert(called == 2); + called = 0; + + assert(d(one, one) == false); + assert(called == 1); + called = 0; + + assert(d(two, one) == false); + assert(called == 1); + called = 0; + } + { + typedef TwoWayHomoComparator C; + typedef __debug_less D; + C c; + D d(c); + + assert(d(one, three) == true); + assert(called == 2); + called = 0; + + assert(d(three, one) == false); + assert(called == 1); + called = 0; + } + { + typedef OneWayHomoComparator C; + typedef __debug_less D; + C c; + D d(c); + + assert(d(one, three) == true); + assert(called == 1); + called = 0; + } +} + +template +struct Tag { + explicit Tag(int v) : value(v) {} + int value; +}; + +template +struct FooImp { + explicit FooImp(int x) : x_(x) {} + int x_; +}; + +template +inline bool operator<(FooImp const& x, Tag<0> y) { + return x.x_ < y.value; +} + +template +inline bool operator<(Tag<0>, FooImp const&) { + static_assert(sizeof(FooImp) != sizeof(FooImp), "should not be instantiated"); + return false; +} + +template +inline bool operator<(Tag<1> x, FooImp const& y) { + return x.value < y.x_; +} + +template +inline bool operator<(FooImp const&, Tag<1>) { + static_assert(sizeof(FooImp) != sizeof(FooImp), "should not be instantiated"); + return false; +} + +typedef FooImp<> Foo; + +// Test that we don't attempt to call the comparator with the arguments reversed +// for upper_bound and lower_bound since the comparator or type is not required +// to support it, nor does it require the range to have a strict weak ordering. +// See llvm.org/PR39458 +void test_upper_and_lower_bound() { + Foo table[] = {Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)}; + { + Foo* iter = std::lower_bound(std::begin(table), std::end(table), Tag<0>(3)); + assert(iter == (table + 2)); + } + { + Foo* iter = std::upper_bound(std::begin(table), std::end(table), Tag<1>(3)); + assert(iter == (table + 3)); + } +} + +struct NonConstArgCmp { + bool operator()(int& x, int &y) const { + return x < y; + } +}; + +void test_non_const_arg_cmp() { + { + NonConstArgCmp cmp; + __debug_less dcmp(cmp); + int x = 0, y = 1; + assert(dcmp(x, y)); + assert(!dcmp(y, x)); + } + { + NonConstArgCmp cmp; + int arr[] = {5, 4, 3, 2, 1}; + std::sort(std::begin(arr), std::end(arr), cmp); + assert(std::is_sorted(std::begin(arr), std::end(arr))); + } +} + +struct ValueIterator { + typedef std::input_iterator_tag iterator_category; + typedef std::size_t value_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t reference; + typedef std::size_t* pointer; + + ValueIterator() { } + + reference operator*() { return 0; } + ValueIterator& operator++() { return *this; } + + friend bool operator==(ValueIterator, ValueIterator) { return true; } + friend bool operator!=(ValueIterator, ValueIterator) { return false; } +}; + +void test_value_iterator() { + // Ensure no build failures when iterators return values, not references. + assert(0 == std::lexicographical_compare(ValueIterator(), ValueIterator(), + ValueIterator(), ValueIterator())); +} + +void test_value_categories() { + std::less l; + std::__debug_less > dl(l); + int lvalue = 42; + const int const_lvalue = 101; + + assert(dl(lvalue, const_lvalue)); + assert(dl(/*rvalue*/1, lvalue)); + assert(dl(static_cast(1), static_cast(2))); +} + +#if TEST_STD_VER > 11 +constexpr bool test_constexpr() { + std::less<> cmp{}; + __debug_less > dcmp(cmp); + assert(dcmp(1, 2)); + assert(!dcmp(1, 1)); + return true; +} +#endif + +int main(int, char**) { + test_passing(); + test_upper_and_lower_bound(); + test_non_const_arg_cmp(); + test_value_iterator(); + test_value_categories(); +#if TEST_STD_VER > 11 + static_assert(test_constexpr(), ""); +#endif + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/debug_three_way_comp.inconsistent.pass.cpp b/libcxx/test/libcxx-03/algorithms/debug_three_way_comp.inconsistent.pass.cpp new file mode 100644 index 0000000000000..b9bb1c9136f65 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/debug_three_way_comp.inconsistent.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// template struct __debug_three_way_comp + +// Make sure __debug_three_way_comp asserts when the comparator is not consistent. + +// REQUIRES: libcpp-hardening-mode=debug +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +#include +#include + +#include "check_assertion.h" + +struct AlwaysLess { + std::strong_ordering operator()(int, int) const { return std::strong_ordering::less; } +}; + +struct AlwaysGreater { + std::strong_ordering operator()(int, int) const { return std::strong_ordering::greater; } +}; + +struct InconsistentEquals { + std::strong_ordering operator()(int a, int) const { + if (a == 0) + return std::strong_ordering::equal; + return std::strong_ordering::greater; + } +}; + +int main(int, char**) { + int zero = 0; + int one = 1; + + AlwaysLess alwaysLess; + std::__debug_three_way_comp debugAlwaysLess(alwaysLess); + TEST_LIBCPP_ASSERT_FAILURE(debugAlwaysLess(zero, one), "Comparator does not induce a strict weak ordering"); + + AlwaysGreater alwaysGreater; + std::__debug_three_way_comp debugAlwaysGreater(alwaysGreater); + TEST_LIBCPP_ASSERT_FAILURE(debugAlwaysGreater(zero, one), "Comparator does not induce a strict weak ordering"); + + InconsistentEquals inconsistentEquals; + std::__debug_three_way_comp debugInconsistentEquals(inconsistentEquals); + TEST_LIBCPP_ASSERT_FAILURE(debugInconsistentEquals(zero, one), "Comparator does not induce a strict weak ordering"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp b/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp new file mode 100644 index 0000000000000..88a18e8592921 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// __half_positive divides an integer number by 2 as unsigned number for known types. +// It can be an important optimization for lower bound, for example. + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +#include <__algorithm/half_positive.h> +#include +#include +#include + +#include "test_macros.h" +#include "user_defined_integral.h" + +namespace { + +template +TEST_CONSTEXPR bool test(IntType max_v = IntType(std::numeric_limits::max())) { + return std::__half_positive(max_v) == max_v / 2; +} + +} // namespace + +int main(int, char**) +{ + { + assert(test()); + assert(test()); + assert(test()); + assert((test, int>())); + assert(test()); +#if !defined(TEST_HAS_NO_INT128) + assert(test<__int128_t>()); +#endif // !defined(TEST_HAS_NO_INT128) + } + +#if TEST_STD_VER >= 11 + { + static_assert(test(), ""); + static_assert(test(), ""); + static_assert(test(), ""); + static_assert(test(), ""); +#if !defined(TEST_HAS_NO_INT128) + static_assert(test<__int128_t>(), ""); +#endif // !defined(TEST_HAS_NO_INT128) + } +#endif // TEST_STD_VER >= 11 + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/lifetimebound.verify.cpp b/libcxx/test/libcxx-03/algorithms/lifetimebound.verify.cpp new file mode 100644 index 0000000000000..6bb1a4c6bbe3d --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/lifetimebound.verify.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// ADDITIONAL_COMPILE_FLAGS: -Wno-pessimizing-move -Wno-unused-variable + +#include + +#include "test_macros.h" + +struct Comp { + template + bool operator()(T, U) { + return false; + } +}; + +void func() { + int i = 0; + { + auto&& v1 = std::min(0, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::min(i, 0); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::min(0, i, Comp{}); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::min(i, 0, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + } + { + auto&& v1 = std::max(0, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::max(i, 0); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::max(0, i, Comp{}); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::max(i, 0, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + } + { + auto&& v1 = std::minmax(0, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::minmax(i, 0); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::minmax(0, i, Comp{}); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::minmax(i, 0, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + auto v5 = std::minmax(0, i); // expected-warning {{temporary whose address is used as value of local variable 'v5' will be destroyed at the end of the full-expression}} + auto v6 = std::minmax(i, 0); // expected-warning {{temporary whose address is used as value of local variable 'v6' will be destroyed at the end of the full-expression}} + auto v7 = std::minmax(0, i, Comp{}); // expected-warning {{temporary whose address is used as value of local variable 'v7' will be destroyed at the end of the full-expression}} + auto v8 = std::minmax(i, 0, Comp{}); // expected-warning {{temporary whose address is used as value of local variable 'v8' will be destroyed at the end of the full-expression}} + } +#if TEST_STD_VER >= 17 + { + auto&& v1 = std::clamp(1, i, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::clamp(i, 1, i); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::clamp(i, i, 1); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::clamp(1, i, i, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + auto&& v5 = std::clamp(i, 1, i, Comp{}); // expected-warning {{temporary bound to local reference 'v5' will be destroyed at the end of the full-expression}} + auto&& v6 = std::clamp(i, i, 1, Comp{}); // expected-warning {{temporary bound to local reference 'v6' will be destroyed at the end of the full-expression}} + } +#endif +#if TEST_STD_VER >= 20 + { + auto&& v1 = std::ranges::min(0, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::ranges::min(i, 0); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::ranges::min(0, i, Comp{}); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::ranges::min(i, 0, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + } + { + auto&& v1 = std::ranges::max(0, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::ranges::max(i, 0); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::ranges::max(0, i, Comp{}); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::ranges::max(i, 0, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + } + { + auto&& v1 = std::ranges::minmax(0, i); // expected-warning {{temporary bound to local reference 'v1' will be destroyed at the end of the full-expression}} + auto&& v2 = std::ranges::minmax(i, 0); // expected-warning {{temporary bound to local reference 'v2' will be destroyed at the end of the full-expression}} + auto&& v3 = std::ranges::minmax(0, i, Comp{}); // expected-warning {{temporary bound to local reference 'v3' will be destroyed at the end of the full-expression}} + auto&& v4 = std::ranges::minmax(i, 0, Comp{}); // expected-warning {{temporary bound to local reference 'v4' will be destroyed at the end of the full-expression}} + auto v5 = std::ranges::minmax(0, i); // expected-warning {{temporary whose address is used as value of local variable 'v5' will be destroyed at the end of the full-expression}} + auto v6 = std::ranges::minmax(i, 0); // expected-warning {{temporary whose address is used as value of local variable 'v6' will be destroyed at the end of the full-expression}} + auto v7 = std::ranges::minmax(0, i, Comp{}); // expected-warning {{temporary whose address is used as value of local variable 'v7' will be destroyed at the end of the full-expression}} + auto v8 = std::ranges::minmax(i, 0, Comp{}); // expected-warning {{temporary whose address is used as value of local variable 'v8' will be destroyed at the end of the full-expression}} + } +#endif // TEST_STD_VER >= 20 +} diff --git a/libcxx/test/libcxx-03/algorithms/no_specializations.verify.cpp b/libcxx/test/libcxx-03/algorithms/no_specializations.verify.cpp new file mode 100644 index 0000000000000..5b2475252b602 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/no_specializations.verify.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14 + +// UNSUPPORTED: libcpp-has-no-incomplete-pstl + +// Check that user-specializations are diagnosed +// See [execpol.type]/3 + +#include + +#if !__has_warning("-Winvalid-specializations") +// expected-no-diagnostics +#else +struct S {}; + +template <> +struct std::is_execution_policy; // expected-error {{cannot be specialized}} + +template <> +constexpr bool std::is_execution_policy_v = false; // expected-error {{cannot be specialized}} +#endif diff --git a/libcxx/test/libcxx-03/algorithms/nth_element_stability.pass.cpp b/libcxx/test/libcxx-03/algorithms/nth_element_stability.pass.cpp new file mode 100644 index 0000000000000..7124e54c2285b --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/nth_element_stability.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// Test std::nth_element stability randomization + +// UNSUPPORTED: c++03 +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +struct MyType { + int value = 0; + constexpr bool operator<(const MyType& other) const { return value < other.value; } +}; + +std::vector deterministic() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = (i % 2 ? i : kSize / 2 + i); + } + std::__nth_element(v.begin(), v.begin() + kSize / 2, v.end(), std::less()); + return v; +} + +void test_randomization() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = (i % 2 ? i : kSize / 2 + i); + } + auto deterministic_v = deterministic(); + std::nth_element(v.begin(), v.begin() + kSize / 2, v.end()); + bool all_equal = true; + for (int i = 0; i < kSize; ++i) { + if (v[i].value != deterministic_v[i].value) { + all_equal = false; + } + } + assert(!all_equal); +} + +void test_same() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = (i % 2 ? i : kSize / 2 + i); + } + auto snapshot_v = v; + auto snapshot_custom_v = v; + std::nth_element(v.begin(), v.begin() + kSize / 2, v.end()); + std::nth_element(snapshot_v.begin(), snapshot_v.begin() + kSize / 2, snapshot_v.end()); + std::nth_element(snapshot_custom_v.begin(), snapshot_custom_v.begin() + kSize / 2, snapshot_custom_v.end(), std::less()); + bool all_equal = true; + for (int i = 0; i < kSize; ++i) { + if (v[i].value != snapshot_v[i].value || v[i].value != snapshot_custom_v[i].value) { + all_equal = false; + } + if (i < kSize / 2) { + assert(v[i].value <= v[kSize / 2].value); + } + } + assert(all_equal); +} + +#if TEST_STD_VER > 17 +constexpr bool test_constexpr() { + std::array v; + for (int i = 9; i >= 0; --i) { + v[9 - i].value = i; + } + std::nth_element(v.begin(), v.begin() + 5, v.end()); + return std::is_partitioned(v.begin(), v.end(), [&](const MyType& m) { return m.value <= v[5].value; }); +} +#endif + +int main(int, char**) { + test_randomization(); + test_same(); +#if TEST_STD_VER > 17 + static_assert(test_constexpr(), ""); +#endif + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/partial_sort_stability.pass.cpp b/libcxx/test/libcxx-03/algorithms/partial_sort_stability.pass.cpp new file mode 100644 index 0000000000000..3f9a5a0bd7708 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/partial_sort_stability.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// Test std::partial_sort stability randomization + +// UNSUPPORTED: c++03 +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +struct MyType { + int value = 0; + constexpr bool operator<(const MyType& other) const { return value < other.value; } +}; + +std::vector deterministic() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = (i % 2 ? 1 : kSize / 2 + i); + } + auto comp = std::less(); + std::__partial_sort_impl(v.begin(), v.begin() + kSize / 2, v.end(), comp); + return v; +} + +void test_randomization() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = (i % 2 ? 1 : kSize / 2 + i); + } + auto deterministic_v = deterministic(); + std::partial_sort(v.begin(), v.begin() + kSize / 2, v.end()); + bool all_equal = true; + for (int i = 0; i < kSize; ++i) { + if (v[i].value != deterministic_v[i].value) { + all_equal = false; + } + } + assert(!all_equal); +} + +void test_same() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = (i % 2 ? 1 : kSize / 2 + i); + } + auto snapshot_v = v; + auto snapshot_custom_v = v; + std::partial_sort(v.begin(), v.begin() + kSize / 2, v.end()); + std::partial_sort(snapshot_v.begin(), snapshot_v.begin() + kSize / 2, snapshot_v.end()); + std::partial_sort(snapshot_custom_v.begin(), snapshot_custom_v.begin() + kSize / 2, snapshot_custom_v.end(), std::less()); + bool all_equal = true; + for (int i = 0; i < kSize; ++i) { + if (v[i].value != snapshot_v[i].value || v[i].value != snapshot_custom_v[i].value) { + all_equal = false; + } + if (i < kSize / 2) { + assert(v[i].value == 1); + } + } + assert(all_equal); +} + +#if TEST_STD_VER > 17 +constexpr bool test_constexpr() { + std::array v; + for (int i = 9; i >= 0; --i) { + v[9 - i].value = i; + } + std::partial_sort(v.begin(), v.begin() + 5, v.end()); + return std::is_sorted(v.begin(), v.begin() + 5); +} +#endif + +int main(int, char**) { + test_randomization(); + test_same(); +#if TEST_STD_VER > 17 + static_assert(test_constexpr(), ""); +#endif + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/pstl.iterator-requirements.verify.cpp b/libcxx/test/libcxx-03/algorithms/pstl.iterator-requirements.verify.cpp new file mode 100644 index 0000000000000..e5bd7e764c59b --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/pstl.iterator-requirements.verify.cpp @@ -0,0 +1,193 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14 +// REQUIRES: stdlib=libc++ +// UNSUPPORTED: libcpp-has-no-incomplete-pstl + +// +// + +// Make sure that all PSTL algorithms contain checks for iterator requirements. +// This is not a requirement from the Standard, but we strive to catch misuse in +// the PSTL both because we can, and because iterator category mistakes in the +// PSTL can lead to subtle bugs. + +// Ignore spurious errors after the initial static_assert failure. +// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error + +// We only diagnose this in C++20 and above because we implement the checks with concepts. +// UNSUPPORTED: c++17 + +#include +#include +#include +#include + +#include "test_iterators.h" + +using non_forward_iterator = cpp17_input_iterator; +struct non_output_iterator : forward_iterator { + constexpr int const& operator*() const; // prevent it from being an output iterator +}; + +void f(non_forward_iterator non_fwd, non_output_iterator non_output, std::execution::sequenced_policy pol) { + auto pred = [](auto&&...) -> bool { return true; }; + auto func = [](auto&&...) -> int { return 1; }; + int* it = nullptr; + int* out = nullptr; + std::size_t n = 0; + int val = 0; + + { + (void)std::any_of(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: any_of}} + (void)std::all_of(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: all_of}} + (void)std::none_of(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: none_of}} + } + + { + (void)std::copy(pol, non_fwd, non_fwd, it); // expected-error@*:* {{static assertion failed: copy}} + (void)std::copy(pol, it, it, non_fwd); // expected-error@*:* {{static assertion failed: copy}} + (void)std::copy(pol, it, it, non_output); // expected-error@*:* {{static assertion failed: copy}} + } + { + (void)std::copy_n(pol, non_fwd, n, it); // expected-error@*:* {{static assertion failed: copy_n}} + (void)std::copy_n(pol, it, n, non_fwd); // expected-error@*:* {{static assertion failed: copy_n}} + (void)std::copy_n(pol, it, n, non_output); // expected-error@*:* {{static assertion failed: copy_n}} + } + + { + (void)std::count(pol, non_fwd, non_fwd, val); // expected-error@*:* {{static assertion failed: count}} + (void)std::count_if(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: count_if}} + } + + { + (void)std::equal(pol, non_fwd, non_fwd, it); // expected-error@*:* {{static assertion failed: equal}} + (void)std::equal(pol, it, it, non_fwd); // expected-error@*:* {{static assertion failed: equal}} + (void)std::equal(pol, non_fwd, non_fwd, it, pred); // expected-error@*:* {{static assertion failed: equal}} + (void)std::equal(pol, it, it, non_fwd, pred); // expected-error@*:* {{static assertion failed: equal}} + + (void)std::equal(pol, non_fwd, non_fwd, it, it); // expected-error@*:* {{static assertion failed: equal}} + (void)std::equal(pol, it, it, non_fwd, non_fwd); // expected-error@*:* {{static assertion failed: equal}} + (void)std::equal(pol, non_fwd, non_fwd, it, it, pred); // expected-error@*:* {{static assertion failed: equal}} + (void)std::equal(pol, it, it, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: equal}} + } + + { + (void)std::fill(pol, non_fwd, non_fwd, val); // expected-error@*:* {{static assertion failed: fill}} + (void)std::fill_n(pol, non_fwd, n, val); // expected-error@*:* {{static assertion failed: fill_n}} + } + + { + (void)std::find(pol, non_fwd, non_fwd, val); // expected-error@*:* {{static assertion failed: find}} + (void)std::find_if(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: find_if}} + (void)std::find_if_not(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: find_if_not}} + } + + { + (void)std::for_each(pol, non_fwd, non_fwd, func); // expected-error@*:* {{static assertion failed: for_each}} + (void)std::for_each_n(pol, non_fwd, n, func); // expected-error@*:* {{static assertion failed: for_each_n}} + } + + { + (void)std::generate(pol, non_fwd, non_fwd, func); // expected-error@*:* {{static assertion failed: generate}} + (void)std::generate_n(pol, non_fwd, n, func); // expected-error@*:* {{static assertion failed: generate_n}} + } + + { + (void)std::is_partitioned( + pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: is_partitioned}} + } + + { + (void)std::merge(pol, non_fwd, non_fwd, it, it, out); // expected-error@*:* {{static assertion failed: merge}} + (void)std::merge(pol, it, it, non_fwd, non_fwd, out); // expected-error@*:* {{static assertion failed: merge}} + (void)std::merge(pol, it, it, it, it, non_output); // expected-error@*:* {{static assertion failed: merge}} + + (void)std::merge(pol, non_fwd, non_fwd, it, it, out, pred); // expected-error@*:* {{static assertion failed: merge}} + (void)std::merge(pol, it, it, non_fwd, non_fwd, out, pred); // expected-error@*:* {{static assertion failed: merge}} + (void)std::merge(pol, it, it, it, it, non_output, pred); // expected-error@*:* {{static assertion failed: merge}} + } + + { + (void)std::move(pol, non_fwd, non_fwd, out); // expected-error@*:* {{static assertion failed: move}} + (void)std::move(pol, it, it, non_fwd); // expected-error@*:* {{static assertion failed: move}} + (void)std::move(pol, it, it, non_output); // expected-error@*:* {{static assertion failed: move}} + } + + { + (void)std::replace_if( + pol, non_fwd, non_fwd, pred, val); // expected-error@*:* {{static assertion failed: replace_if}} + (void)std::replace(pol, non_fwd, non_fwd, val, val); // expected-error@*:* {{static assertion failed: replace}} + + (void)std::replace_copy_if( + pol, non_fwd, non_fwd, out, pred, val); // expected-error@*:* {{static assertion failed: replace_copy_if}} + (void)std::replace_copy_if( + pol, it, it, non_fwd, pred, val); // expected-error@*:* {{static assertion failed: replace_copy_if}} + (void)std::replace_copy_if( + pol, it, it, non_output, pred, val); // expected-error@*:* {{static assertion failed: replace_copy_if}} + + (void)std::replace_copy( + pol, non_fwd, non_fwd, out, val, val); // expected-error@*:* {{static assertion failed: replace_copy}} + (void)std::replace_copy( + pol, it, it, non_fwd, val, val); // expected-error@*:* {{static assertion failed: replace_copy}} + (void)std::replace_copy( + pol, it, it, non_output, val, val); // expected-error@*:* {{static assertion failed: replace_copy}} + } + + { + (void)std::rotate_copy( + pol, non_fwd, non_fwd, non_fwd, out); // expected-error@*:* {{static assertion failed: rotate_copy}} + (void)std::rotate_copy(pol, it, it, it, non_fwd); // expected-error@*:* {{static assertion failed: rotate_copy}} + (void)std::rotate_copy(pol, it, it, it, non_output); // expected-error@*:* {{static assertion failed: rotate_copy}} + } + + { + (void)std::sort(pol, non_fwd, non_fwd); // expected-error@*:* {{static assertion failed: sort}} + (void)std::sort(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: sort}} + } + + { + (void)std::stable_sort(pol, non_fwd, non_fwd); // expected-error@*:* {{static assertion failed: stable_sort}} + (void)std::stable_sort(pol, non_fwd, non_fwd, pred); // expected-error@*:* {{static assertion failed: stable_sort}} + } + + { + (void)std::transform(pol, non_fwd, non_fwd, out, func); // expected-error@*:* {{static assertion failed: transform}} + (void)std::transform(pol, it, it, non_fwd, func); // expected-error@*:* {{static assertion failed: transform}} + (void)std::transform(pol, it, it, non_output, func); // expected-error@*:* {{static assertion failed: transform}} + + (void)std::transform( + pol, non_fwd, non_fwd, it, out, func); // expected-error@*:* {{static assertion failed: transform}} + (void)std::transform(pol, it, it, non_fwd, out, func); // expected-error@*:* {{static assertion failed: transform}} + (void)std::transform(pol, it, it, it, non_fwd, func); // expected-error@*:* {{static assertion failed: transform}} + (void)std::transform( + pol, it, it, it, non_output, func); // expected-error@*:* {{static assertion failed: transform}} + } + + { + (void)std::reduce(pol, non_fwd, non_fwd); // expected-error@*:* {{static assertion failed: reduce}} + (void)std::reduce(pol, non_fwd, non_fwd, val); // expected-error@*:* {{static assertion failed: reduce}} + (void)std::reduce(pol, non_fwd, non_fwd, val, func); // expected-error@*:* {{static assertion failed: reduce}} + } + + { + (void)std::transform_reduce( + pol, non_fwd, non_fwd, it, val); // expected-error@*:* {{static assertion failed: transform_reduce}} + (void)std::transform_reduce( + pol, it, it, non_fwd, val); // expected-error@*:* {{static assertion failed: transform_reduce}} + + (void)std::transform_reduce( + pol, non_fwd, non_fwd, it, val, func, func); // expected-error@*:* {{static assertion failed: transform_reduce}} + (void)std::transform_reduce( + pol, it, it, non_fwd, val, func, func); // expected-error@*:* {{static assertion failed: transform_reduce}} + + (void)std::transform_reduce( + pol, non_fwd, non_fwd, val, func, func); // expected-error@*:* {{static assertion failed: transform_reduce}} + } +} diff --git a/libcxx/test/libcxx-03/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp b/libcxx/test/libcxx-03/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp new file mode 100644 index 0000000000000..b48ac02dd79c5 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// REQUIRES: libcpp-pstl-backend-libdispatch + +// __chunk_partitions __partition_chunks(ptrdiff_t); + +#include <__pstl/backends/libdispatch.h> +#include +#include + +int main(int, char**) { + { + auto chunks = std::__pstl::__libdispatch::__partition_chunks(0); + assert(chunks.__chunk_count_ == 1); + assert(chunks.__first_chunk_size_ == 0); + assert(chunks.__chunk_size_ == 0); + } + + { + auto chunks = std::__pstl::__libdispatch::__partition_chunks(1); + assert(chunks.__chunk_count_ == 1); + assert(chunks.__first_chunk_size_ == 1); + assert(chunks.__chunk_size_ == 1); + } + + for (std::ptrdiff_t i = 2; i != 2ll << 20; ++i) { + auto chunks = std::__pstl::__libdispatch::__partition_chunks(i); + assert(chunks.__chunk_count_ >= 1); + assert(chunks.__chunk_count_ <= i); + assert((chunks.__chunk_count_ - 1) * chunks.__chunk_size_ + chunks.__first_chunk_size_ == i); + } + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_comparators.pass.cpp b/libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_comparators.pass.cpp new file mode 100644 index 0000000000000..dd026444330ea --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_comparators.pass.cpp @@ -0,0 +1,264 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// + +// this test checks that the comparators in the ranges algorithms aren't copied/moved + +#include +#include +#include +#include +#include + +#include "test_macros.h" + +struct Less { + int *copies_; + constexpr explicit Less(int *copies) : copies_(copies) {} + constexpr Less(const Less& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr Less& operator=(const Less&) = default; + constexpr bool operator()(void*, void*) const { return false; } +}; + +struct Equal { + int *copies_; + constexpr explicit Equal(int *copies) : copies_(copies) {} + constexpr Equal(const Equal& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr Equal& operator=(const Equal&) = default; + constexpr bool operator()(void*, void*) const { return true; } +}; + +struct UnaryVoid { + int *copies_; + constexpr explicit UnaryVoid(int *copies) : copies_(copies) {} + constexpr UnaryVoid(const UnaryVoid& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr UnaryVoid& operator=(const UnaryVoid&) = default; + constexpr void operator()(void*) const {} +}; + +struct UnaryTrue { + int *copies_; + constexpr explicit UnaryTrue(int *copies) : copies_(copies) {} + constexpr UnaryTrue(const UnaryTrue& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr UnaryTrue& operator=(const UnaryTrue&) = default; + constexpr bool operator()(void*) const { return true; } +}; + +struct NullaryValue { + int *copies_; + constexpr explicit NullaryValue(int *copies) : copies_(copies) {} + constexpr NullaryValue(const NullaryValue& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr NullaryValue& operator=(const NullaryValue&) = default; + constexpr std::nullptr_t operator()() const { return nullptr; } +}; + +struct UnaryTransform { + int *copies_; + constexpr explicit UnaryTransform(int *copies) : copies_(copies) {} + constexpr UnaryTransform(const UnaryTransform& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr UnaryTransform& operator=(const UnaryTransform&) = default; + constexpr std::nullptr_t operator()(void*) const { return nullptr; } +}; + +struct BinaryTransform { + int *copies_; + constexpr explicit BinaryTransform(int *copies) : copies_(copies) {} + constexpr BinaryTransform(const BinaryTransform& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr BinaryTransform& operator=(const BinaryTransform&) = default; + constexpr std::nullptr_t operator()(void*, void*) const { return nullptr; } +}; + +constexpr bool all_the_algorithms() +{ + void *a[10] = {}; + void *b[10] = {}; + void *half[5] = {}; + void **first = a; + void **mid = a+5; + void **last = a+10; + void **first2 = b; + void **mid2 = b+5; + void **last2 = b+10; + void *value = nullptr; + int count = 1; + + int copies = 0; + (void)std::ranges::adjacent_find(first, last, Equal(&copies)); assert(copies == 0); + (void)std::ranges::adjacent_find(a, Equal(&copies)); assert(copies == 0); + (void)std::ranges::all_of(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::all_of(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::any_of(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::any_of(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::binary_search(first, last, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::binary_search(a, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::clamp(value, value, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::count_if(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::count_if(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::copy_if(first, last, first2, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::copy_if(a, first2, UnaryTrue(&copies)); assert(copies == 0); +#if TEST_STD_VER >= 23 + (void)std::ranges::ends_with(first, last, first2, last2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::ends_with(a, b, Equal(&copies)); assert(copies == 0); +#endif + (void)std::ranges::equal(first, last, first2, last2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::equal(a, b, Equal(&copies)); assert(copies == 0); + (void)std::ranges::equal_range(first, last, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::equal_range(a, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::find_end(first, last, first2, mid2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::find_end(a, b, Equal(&copies)); assert(copies == 0); + (void)std::ranges::find_first_of(first, last, first2, last2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::find_first_of(a, b, Equal(&copies)); assert(copies == 0); + (void)std::ranges::find_if(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::find_if(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::find_if_not(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::find_if_not(a, UnaryTrue(&copies)); assert(copies == 0); +#if TEST_STD_VER >= 23 + (void)std::ranges::find_last_if(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if(a, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if_not(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if_not(a, UnaryTrue(&copies)); + assert(copies == 0); +#endif + (void)std::ranges::for_each(first, last, UnaryVoid(&copies)); assert(copies == 1); copies = 0; + (void)std::ranges::for_each(a, UnaryVoid(&copies)); assert(copies == 1); copies = 0; + (void)std::ranges::for_each_n(first, count, UnaryVoid(&copies)); assert(copies == 1); copies = 0; + (void)std::ranges::generate(first, last, NullaryValue(&copies)); assert(copies == 0); + (void)std::ranges::generate(a, NullaryValue(&copies)); assert(copies == 0); + (void)std::ranges::generate_n(first, count, NullaryValue(&copies)); assert(copies == 0); + (void)std::ranges::includes(first, last, first2, last2, Less(&copies)); assert(copies == 0); + (void)std::ranges::includes(a, b, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_heap(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_heap(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_heap_until(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_heap_until(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_partitioned(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::is_partitioned(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::is_permutation(first, last, first2, last2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::is_permutation(a, b, Equal(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted_until(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted_until(a, Less(&copies)); assert(copies == 0); + if (TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED) { + (void)std::ranges::inplace_merge(first, mid, last, Less(&copies)); + assert(copies == 0); + (void)std::ranges::inplace_merge(a, mid, Less(&copies)); + assert(copies == 0); + } + (void)std::ranges::lexicographical_compare(first, last, first2, last2, Less(&copies)); assert(copies == 0); + (void)std::ranges::lexicographical_compare(a, b, Less(&copies)); assert(copies == 0); + (void)std::ranges::lower_bound(first, last, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::lower_bound(a, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::make_heap(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::make_heap(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::max(value, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::max({ value, value }, Less(&copies)); assert(copies == 0); + (void)std::ranges::max(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::max_element(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::max_element(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::merge(first, mid, mid, last, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::merge(half, half, b, Less(&copies)); assert(copies == 0); + (void)std::ranges::min(value, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::min({ value, value }, Less(&copies)); assert(copies == 0); + (void)std::ranges::min(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::min_element(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::min_element(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::minmax(value, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::minmax({ value, value }, Less(&copies)); assert(copies == 0); + (void)std::ranges::minmax(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::minmax_element(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::minmax_element(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::mismatch(first, last, first2, last2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::mismatch(a, b, Equal(&copies)); assert(copies == 0); + (void)std::ranges::next_permutation(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::next_permutation(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::none_of(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::none_of(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::nth_element(first, mid, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::nth_element(a, mid, Less(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort(first, mid, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort(a, mid, Less(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort_copy(first, last, first2, mid2, Less(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort_copy(a, b, Less(&copies)); assert(copies == 0); + (void)std::ranges::partition(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::partition(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::partition_copy(first, last, first2, last2, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::partition_copy(a, first2, last2, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::partition_point(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::partition_point(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::pop_heap(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::pop_heap(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::prev_permutation(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::prev_permutation(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::push_heap(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::push_heap(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::remove_copy_if(first, last, first2, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::remove_copy_if(a, first2, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::remove_if(first, last, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::remove_if(a, UnaryTrue(&copies)); assert(copies == 0); + (void)std::ranges::replace_copy_if(first, last, first2, UnaryTrue(&copies), value); assert(copies == 0); + (void)std::ranges::replace_copy_if(a, first2, UnaryTrue(&copies), value); assert(copies == 0); + (void)std::ranges::replace_if(first, last, UnaryTrue(&copies), value); assert(copies == 0); + (void)std::ranges::replace_if(a, UnaryTrue(&copies), value); assert(copies == 0); + (void)std::ranges::search(first, last, first2, mid2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::search(a, b, Equal(&copies)); assert(copies == 0); + (void)std::ranges::search_n(first, last, count, value, Equal(&copies)); assert(copies == 0); + (void)std::ranges::search_n(a, count, value, Equal(&copies)); assert(copies == 0); + (void)std::ranges::set_difference(first, mid, mid, last, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_difference(a, b, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_intersection(first, mid, mid, last, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_intersection(a, b, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_symmetric_difference(first, mid, mid, last, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_symmetric_difference(a, b, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_union(first, mid, mid, last, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::set_union(a, b, first2, Less(&copies)); assert(copies == 0); + (void)std::ranges::sort(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::sort(a, Less(&copies)); assert(copies == 0); + (void)std::ranges::sort_heap(first, last, Less(&copies)); assert(copies == 0); + (void)std::ranges::sort_heap(a, Less(&copies)); assert(copies == 0); + if (TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED) { + (void)std::ranges::stable_partition(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::ranges::stable_partition(a, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::ranges::stable_sort(first, last, Less(&copies)); + assert(copies == 0); + (void)std::ranges::stable_sort(a, Less(&copies)); + assert(copies == 0); + } +#if TEST_STD_VER > 20 + (void)std::ranges::starts_with(first, last, first2, last2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::starts_with(a, b, Equal(&copies)); assert(copies == 0); +#endif + (void)std::ranges::transform(first, last, first2, UnaryTransform(&copies)); assert(copies == 0); + (void)std::ranges::transform(a, first2, UnaryTransform(&copies)); assert(copies == 0); + (void)std::ranges::transform(first, mid, mid, last, first2, BinaryTransform(&copies)); assert(copies == 0); + (void)std::ranges::transform(a, b, first2, BinaryTransform(&copies)); assert(copies == 0); + (void)std::ranges::unique(first, last, Equal(&copies)); assert(copies == 0); + (void)std::ranges::unique(a, Equal(&copies)); assert(copies == 0); + (void)std::ranges::unique_copy(first, last, first2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::unique_copy(a, first2, Equal(&copies)); assert(copies == 0); + (void)std::ranges::upper_bound(first, last, value, Less(&copies)); assert(copies == 0); + (void)std::ranges::upper_bound(a, value, Less(&copies)); assert(copies == 0); + + return true; +} + +int main(int, char**) +{ + all_the_algorithms(); + static_assert(all_the_algorithms()); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_projections.pass.cpp b/libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_projections.pass.cpp new file mode 100644 index 0000000000000..4919590ddffdc --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/ranges_robust_against_copying_projections.pass.cpp @@ -0,0 +1,278 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// + +// this test checks that the projections in the ranges algorithms aren't copied/moved + +#include +#include +#include +#include +#include + +#include "test_macros.h" + +struct T {}; + +struct Proj { + int *copies_; + constexpr explicit Proj(int *copies) : copies_(copies) {} + constexpr Proj(const Proj& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr Proj& operator=(const Proj&) = default; + constexpr void* operator()(T) const { return nullptr; } +}; + +struct Less { + constexpr bool operator()(void*, void*) const { return false; } +}; + +struct Equal { + constexpr bool operator()(void*, void*) const { return true; } +}; + +struct UnaryVoid { + constexpr void operator()(void*) const {} +}; + +struct UnaryTrue { + constexpr bool operator()(void*) const { return true; } +}; + +struct NullaryValue { + constexpr std::nullptr_t operator()() const { return nullptr; } +}; + +struct UnaryTransform { + constexpr T operator()(void*) const { return T(); } +}; + +struct BinaryTransform { + constexpr T operator()(void*, void*) const { return T(); } +}; + +constexpr bool all_the_algorithms() +{ + T a[10] = {}; + T b[10] = {}; + T half[5] = {}; + T *first = a; + T *mid = a+5; + T *last = a+10; + T *first2 = b; + T *mid2 = b+5; + T *last2 = b+10; + void *value = nullptr; + int count = 1; + + int copies = 0; + (void)std::ranges::adjacent_find(first, last, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::adjacent_find(a, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::all_of(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::all_of(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::any_of(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::any_of(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::binary_search(first, last, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::binary_search(a, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::clamp(T(), T(), T(), Less(), Proj(&copies)); assert(copies == 0); +#if TEST_STD_VER >= 23 + (void)std::ranges::contains(first, last, value, Proj(&copies)); + assert(copies == 0); + (void)std::ranges::contains(a, value, Proj(&copies)); + assert(copies == 0); + (void)std::ranges::contains_subrange(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::contains_subrange(a, b, Equal(), Proj(&copies), Proj(&copies)); + assert(copies == 0); +#endif + (void)std::ranges::count(first, last, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::count(a, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::count_if(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::count_if(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::copy_if(first, last, first2, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::copy_if(a, first2, UnaryTrue(), Proj(&copies)); assert(copies == 0); +#if TEST_STD_VER >= 23 + (void)std::ranges::ends_with(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::ends_with(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); +#endif + (void)std::ranges::equal(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::equal(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::equal_range(first, last, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::equal_range(a, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find(first, last, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::find(a, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_end(first, last, first2, mid2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_end(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_first_of(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_first_of(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_if(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_if(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_if_not(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::find_if_not(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); +#if TEST_STD_VER >= 23 + (void)std::ranges::find_last(first, last, value, Proj(&copies)); + assert(copies == 0); + (void)std::ranges::find_last(a, value, Proj(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if(first, last, UnaryTrue(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if(a, UnaryTrue(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if_not(first, last, UnaryTrue(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::find_last_if_not(a, UnaryTrue(), Proj(&copies)); + assert(copies == 0); +#endif + (void)std::ranges::for_each(first, last, UnaryVoid(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::for_each(a, UnaryVoid(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::for_each_n(first, count, UnaryVoid(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::includes(first, last, first2, last2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::includes(a, b, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_heap(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_heap(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_heap_until(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_heap_until(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_partitioned(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_partitioned(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_permutation(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_permutation(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted_until(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::is_sorted_until(a, Less(), Proj(&copies)); assert(copies == 0); + if (TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED) { + (void)std::ranges::inplace_merge(first, mid, last, Less(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::inplace_merge(a, mid, Less(), Proj(&copies)); + assert(copies == 0); + } + (void)std::ranges::lexicographical_compare(first, last, first2, last2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::lexicographical_compare(a, b, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::lower_bound(first, last, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::lower_bound(a, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::make_heap(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::make_heap(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::max(T(), T(), Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::max({ T(), T() }, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::max(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::max_element(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::max_element(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::merge(first, mid, mid, last, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::merge(half, half, b, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::min(T(), T(), Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::min({ T(), T() }, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::min(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::min_element(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::min_element(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::minmax(T(), T(), Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::minmax({ T(), T() }, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::minmax(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::minmax_element(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::minmax_element(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::mismatch(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::mismatch(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::next_permutation(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::next_permutation(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::none_of(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::none_of(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::nth_element(first, mid, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::nth_element(a, mid, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort(first, mid, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort(a, mid, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort_copy(first, last, first2, mid2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partial_sort_copy(a, b, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partition(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partition(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partition_copy(first, last, first2, last2, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partition_copy(a, first2, last2, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partition_point(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::partition_point(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::pop_heap(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::pop_heap(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::prev_permutation(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::prev_permutation(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::push_heap(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::push_heap(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove_copy(first, last, first2, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove_copy(a, first2, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove_copy_if(first, last, first2, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove_copy_if(a, first2, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove(first, last, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove(a, value, Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove_if(first, last, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::remove_if(a, UnaryTrue(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace_copy(first, last, first2, value, T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace_copy(a, first2, value, T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace_copy_if(first, last, first2, UnaryTrue(), T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace_copy_if(a, first2, UnaryTrue(), T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace(first, last, value, T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace(a, value, T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace_if(first, last, UnaryTrue(), T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::replace_if(a, UnaryTrue(), T(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::search(first, last, first2, mid2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::search(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::search_n(first, last, count, value, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::search_n(a, count, value, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_difference(first, mid, mid, last, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_difference(a, b, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_intersection(first, mid, mid, last, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_intersection(a, b, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_symmetric_difference(first, mid, mid, last, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_symmetric_difference(a, b, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_union(first, mid, mid, last, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::set_union(a, b, first2, Less(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::sort(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::sort(a, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::sort_heap(first, last, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::sort_heap(a, Less(), Proj(&copies)); assert(copies == 0); + if (TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED) { + (void)std::ranges::stable_partition(first, last, UnaryTrue(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::stable_partition(a, UnaryTrue(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::stable_sort(first, last, Less(), Proj(&copies)); + assert(copies == 0); + (void)std::ranges::stable_sort(a, Less(), Proj(&copies)); + assert(copies == 0); + } +#if TEST_STD_VER > 20 + (void)std::ranges::starts_with(first, last, first2, last2, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::starts_with(a, b, Equal(), Proj(&copies), Proj(&copies)); assert(copies == 0); +#endif + (void)std::ranges::transform(first, last, first2, UnaryTransform(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::transform(a, first2, UnaryTransform(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::transform(first, mid, mid, last, first2, BinaryTransform(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::transform(a, b, first2, BinaryTransform(), Proj(&copies), Proj(&copies)); assert(copies == 0); + (void)std::ranges::unique(first, last, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::unique(a, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::unique_copy(first, last, first2, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::unique_copy(a, first2, Equal(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::upper_bound(first, last, value, Less(), Proj(&copies)); assert(copies == 0); + (void)std::ranges::upper_bound(a, value, Less(), Proj(&copies)); assert(copies == 0); + + return true; +} + +void test_deque() { + std::deque d; + int copies = 0; + void* value = nullptr; + + (void)std::ranges::find(d, value, Proj(&copies)); + assert(copies == 0); +} + +int main(int, char**) { + test_deque(); + all_the_algorithms(); + static_assert(all_the_algorithms()); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/robust_against_copying_comparators.pass.cpp b/libcxx/test/libcxx-03/algorithms/robust_against_copying_comparators.pass.cpp new file mode 100644 index 0000000000000..256251686bb3e --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/robust_against_copying_comparators.pass.cpp @@ -0,0 +1,323 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +template +struct Less { + int* copies_; + TEST_CONSTEXPR explicit Less(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 Less(const Less& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 Less& operator=(const Less&) = default; + TEST_CONSTEXPR bool operator()(T, T) const { return false; } +}; + +template +struct Equal { + int* copies_; + TEST_CONSTEXPR explicit Equal(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 Equal(const Equal& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 Equal& operator=(const Equal&) = default; + TEST_CONSTEXPR bool operator()(T, T) const { return true; } +}; + +template +struct UnaryVoid { + int* copies_; + TEST_CONSTEXPR explicit UnaryVoid(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 UnaryVoid(const UnaryVoid& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 UnaryVoid& operator=(const UnaryVoid&) = default; + TEST_CONSTEXPR_CXX14 void operator()(T) const {} +}; + +template +struct UnaryTrue { + int* copies_; + TEST_CONSTEXPR explicit UnaryTrue(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 UnaryTrue(const UnaryTrue& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 UnaryTrue& operator=(const UnaryTrue&) = default; + TEST_CONSTEXPR bool operator()(T) const { return true; } +}; + +template +struct NullaryValue { + int* copies_; + TEST_CONSTEXPR explicit NullaryValue(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 NullaryValue(const NullaryValue& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 NullaryValue& operator=(const NullaryValue&) = default; + TEST_CONSTEXPR T operator()() const { return 0; } +}; + +template +struct UnaryTransform { + int* copies_; + TEST_CONSTEXPR explicit UnaryTransform(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 UnaryTransform(const UnaryTransform& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 UnaryTransform& operator=(const UnaryTransform&) = default; + TEST_CONSTEXPR T operator()(T) const { return 0; } +}; + +template +struct BinaryTransform { + int* copies_; + TEST_CONSTEXPR explicit BinaryTransform(int* copies) : copies_(copies) {} + TEST_CONSTEXPR_CXX14 BinaryTransform(const BinaryTransform& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + TEST_CONSTEXPR_CXX14 BinaryTransform& operator=(const BinaryTransform&) = default; + TEST_CONSTEXPR T operator()(T, T) const { return 0; } +}; + +#if TEST_STD_VER > 17 +template +struct ThreeWay { + int* copies_; + constexpr explicit ThreeWay(int* copies) : copies_(copies) {} + constexpr ThreeWay(const ThreeWay& rhs) : copies_(rhs.copies_) { *copies_ += 1; } + constexpr ThreeWay& operator=(const ThreeWay&) = default; + constexpr std::strong_ordering operator()(T, T) const { return std::strong_ordering::equal; } +}; +#endif + +template +TEST_CONSTEXPR_CXX20 bool all_the_algorithms() { + T a[10] = {}; + T b[10] = {}; + T* first = a; + T* mid = a + 5; + T* last = a + 10; + T* first2 = b; + T* mid2 = b + 5; + T* last2 = b + 10; + T value = 0; + int count = 1; + + int copies = 0; + (void)std::adjacent_find(first, last, Equal(&copies)); + assert(copies == 0); +#if TEST_STD_VER >= 11 + (void)std::all_of(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::any_of(first, last, UnaryTrue(&copies)); + assert(copies == 0); +#endif + (void)std::binary_search(first, last, value, Less(&copies)); + assert(copies == 0); +#if TEST_STD_VER > 17 + (void)std::clamp(value, value, value, Less(&copies)); + assert(copies == 0); +#endif + (void)std::count_if(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::copy_if(first, last, first2, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::equal(first, last, first2, Equal(&copies)); + assert(copies == 0); +#if TEST_STD_VER > 11 + (void)std::equal(first, last, first2, last2, Equal(&copies)); + assert(copies == 0); +#endif + (void)std::equal_range(first, last, value, Less(&copies)); + assert(copies == 0); + (void)std::find_end(first, last, first2, mid2, Equal(&copies)); + assert(copies == 0); + (void)std::find_first_of(first, last, first2, last2, Equal(&copies)); + assert(copies == 0); + (void)std::find_if(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::find_if_not(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::for_each(first, last, UnaryVoid(&copies)); + assert(copies == 1); + copies = 0; +#if TEST_STD_VER > 14 + (void)std::for_each_n(first, count, UnaryVoid(&copies)); + assert(copies == 0); +#endif + (void)std::generate(first, last, NullaryValue(&copies)); + assert(copies == 0); + (void)std::generate_n(first, count, NullaryValue(&copies)); + assert(copies == 0); + (void)std::includes(first, last, first2, last2, Less(&copies)); + assert(copies == 0); + (void)std::is_heap(first, last, Less(&copies)); + assert(copies == 0); + (void)std::is_heap_until(first, last, Less(&copies)); + assert(copies == 0); + (void)std::is_partitioned(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::is_permutation(first, last, first2, Equal(&copies)); + assert(copies == 0); +#if TEST_STD_VER > 11 + (void)std::is_permutation(first, last, first2, last2, Equal(&copies)); + assert(copies == 0); +#endif + (void)std::is_sorted(first, last, Less(&copies)); + assert(copies == 0); + (void)std::is_sorted_until(first, last, Less(&copies)); + assert(copies == 0); + if (!TEST_IS_CONSTANT_EVALUATED) { + (void)std::inplace_merge(first, mid, last, Less(&copies)); + assert(copies == 0); + } + (void)std::lexicographical_compare(first, last, first2, last2, Less(&copies)); + assert(copies == 0); +#if TEST_STD_VER > 17 + (void)std::lexicographical_compare_three_way(first, last, first2, last2, ThreeWay(&copies)); + assert(copies == 0); +#endif + (void)std::lower_bound(first, last, value, Less(&copies)); + assert(copies == 0); + (void)std::make_heap(first, last, Less(&copies)); + assert(copies == 0); + (void)std::max(value, value, Less(&copies)); + assert(copies == 0); +#if TEST_STD_VER >= 11 + (void)std::max({value, value}, Less(&copies)); + assert(copies == 0); +#endif + (void)std::max_element(first, last, Less(&copies)); + assert(copies == 0); + (void)std::merge(first, mid, mid, last, first2, Less(&copies)); + assert(copies == 0); + (void)std::min(value, value, Less(&copies)); + assert(copies == 0); +#if TEST_STD_VER >= 11 + (void)std::min({value, value}, Less(&copies)); + assert(copies == 0); +#endif + (void)std::min_element(first, last, Less(&copies)); + assert(copies == 0); + (void)std::minmax(value, value, Less(&copies)); + assert(copies == 0); +#if TEST_STD_VER >= 11 + (void)std::minmax({value, value}, Less(&copies)); + assert(copies == 0); +#endif + (void)std::minmax_element(first, last, Less(&copies)); + assert(copies == 0); + (void)std::mismatch(first, last, first2, Equal(&copies)); + assert(copies == 0); +#if TEST_STD_VER > 11 + (void)std::mismatch(first, last, first2, last2, Equal(&copies)); + assert(copies == 0); +#endif + (void)std::next_permutation(first, last, Less(&copies)); + assert(copies == 0); +#if TEST_STD_VER >= 11 + (void)std::none_of(first, last, UnaryTrue(&copies)); + assert(copies == 0); +#endif + (void)std::nth_element(first, mid, last, Less(&copies)); + assert(copies == 0); + (void)std::partial_sort(first, mid, last, Less(&copies)); + assert(copies == 0); + (void)std::partial_sort_copy(first, last, first2, mid2, Less(&copies)); + assert(copies == 0); + (void)std::partition(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::partition_copy(first, last, first2, last2, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::partition_point(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::pop_heap(first, last, Less(&copies)); + assert(copies == 0); + (void)std::prev_permutation(first, last, Less(&copies)); + assert(copies == 0); + (void)std::push_heap(first, last, Less(&copies)); + assert(copies == 0); + (void)std::remove_copy_if(first, last, first2, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::remove_if(first, last, UnaryTrue(&copies)); + assert(copies == 0); + (void)std::replace_copy_if(first, last, first2, UnaryTrue(&copies), value); + assert(copies == 0); + (void)std::replace_if(first, last, UnaryTrue(&copies), value); + assert(copies == 0); + (void)std::search(first, last, first2, mid2, Equal(&copies)); + assert(copies == 0); + (void)std::search_n(first, last, count, value, Equal(&copies)); + assert(copies == 0); + (void)std::set_difference(first, mid, mid, last, first2, Less(&copies)); + assert(copies == 0); + (void)std::set_intersection(first, mid, mid, last, first2, Less(&copies)); + assert(copies == 0); + (void)std::set_symmetric_difference(first, mid, mid, last, first2, Less(&copies)); + assert(copies == 0); + (void)std::set_union(first, mid, mid, last, first2, Less(&copies)); + assert(copies == 0); + (void)std::sort(first, first + 3, Less(&copies)); + assert(copies == 0); + (void)std::sort(first, first + 4, Less(&copies)); + assert(copies == 0); + (void)std::sort(first, first + 5, Less(&copies)); + assert(copies == 0); + (void)std::sort(first, last, Less(&copies)); + assert(copies == 0); + (void)std::sort_heap(first, last, Less(&copies)); + assert(copies == 0); + if (!TEST_IS_CONSTANT_EVALUATED) { + (void)std::stable_partition(first, last, UnaryTrue(&copies)); + assert(copies == 0); + } + if (!TEST_IS_CONSTANT_EVALUATED) { + (void)std::stable_sort(first, last, Less(&copies)); + assert(copies == 0); + } + (void)std::transform(first, last, first2, UnaryTransform(&copies)); + assert(copies == 0); + (void)std::transform(first, mid, mid, first2, BinaryTransform(&copies)); + assert(copies == 0); + (void)std::unique(first, last, Equal(&copies)); + assert(copies == 0); + (void)std::unique_copy(first, last, first2, Equal(&copies)); + assert(copies == 0); + (void)std::upper_bound(first, last, value, Less(&copies)); + assert(copies == 0); + + return true; +} + +bool test_segmented_iterator() { + int copies = 0; + std::deque dq(10); + (void)std::for_each(dq.begin(), dq.end(), UnaryVoid(&copies)); + assert(copies == 1); + copies = 0; + +#if TEST_STD_VER >= 20 + std::vector> vecs(3, std::vector(10)); + auto v = std::views::join(vecs); + (void)std::for_each(v.begin(), v.end(), UnaryVoid(&copies)); + assert(copies == 1); + copies = 0; +#endif + + return true; +} + +int main(int, char**) { + all_the_algorithms(); + all_the_algorithms(); + assert(test_segmented_iterator()); +#if TEST_STD_VER > 17 + static_assert(all_the_algorithms()); + static_assert(all_the_algorithms()); +#endif + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp new file mode 100644 index 0000000000000..03fef57ee259a --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp @@ -0,0 +1,225 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Check that all STL classic algorithms can be instantiated with a C++20-hostile iterator + +// ADDITIONAL_COMPILE_FLAGS: -Wno-ambiguous-reversed-operator + +#include +#include +#include +#include + +#include "test_macros.h" + +template +struct IteratorAdaptorBase { + using OutTraits = std::iterator_traits; + using iterator_category = typename OutTraits::iterator_category; + using value_type = typename OutTraits::value_type; + using pointer = typename OutTraits::pointer; + using reference = typename OutTraits::reference; + using difference_type = typename OutTraits::difference_type; + + IteratorAdaptorBase() {} + IteratorAdaptorBase(Iterator) {} + + Sub& sub() { return static_cast(*this); } + const Sub& sub() const { return static_cast(*this); } + + const Iterator& base() const { return it_; } + + reference get() const { return *it_; } + reference operator*() const { return *it_; } + pointer operator->() const { return it_; } + reference operator[](difference_type) const { return *it_; } + + Sub& operator++() { return static_cast(*this); } + Sub& operator--() { return static_cast(*this); } + Sub operator++(int) { return static_cast(*this); } + Sub operator--(int) { return static_cast(*this); } + + Sub& operator+=(difference_type) { return static_cast(*this); } + Sub& operator-=(difference_type) { return static_cast(*this); } + bool operator==(Sub) const { return false; } + bool operator!=(Sub) const { return false; } + bool operator==(Iterator b) const { return *this == Sub(b); } + bool operator!=(Iterator b) const { return *this != Sub(b); } + + friend Sub operator+(Sub, difference_type) { return Sub(); } + friend Sub operator+(difference_type, Sub) { return Sub(); } + friend Sub operator-(Sub, difference_type) { return Sub(); } + friend difference_type operator-(Sub, Sub) { return 0; } + + friend bool operator<(Sub, Sub) { return false; } + friend bool operator>(Sub, Sub) { return false; } + friend bool operator<=(Sub, Sub) { return false; } + friend bool operator>=(Sub, Sub) { return false; } + + private: + Iterator it_; +}; + +template +struct Cpp20HostileIterator + : IteratorAdaptorBase, It> { + Cpp20HostileIterator() {} + Cpp20HostileIterator(It) {} +}; + +struct Pred { + bool operator()(int, int) const { return false; } + bool operator()(int) const { return false; } + int operator()() const { return 0; } +}; + +void test() { + Cpp20HostileIterator it; + Pred pred; + std::mt19937_64 rng; + + (void) std::adjacent_find(it, it); + (void) std::adjacent_find(it, it, pred); + (void) std::all_of(it, it, pred); + (void) std::any_of(it, it, pred); + (void) std::binary_search(it, it, 0); + (void) std::binary_search(it, it, 0, pred); + (void) std::copy_backward(it, it, it); + (void) std::copy_if(it, it, it, pred); + (void) std::copy_n(it, 0, it); + (void) std::copy(it, it, it); + (void) std::count_if(it, it, pred); + (void) std::count(it, it, 0); + (void) std::equal_range(it, it, 0); + (void) std::equal_range(it, it, 0, pred); + (void) std::equal(it, it, it); + (void) std::equal(it, it, it, pred); +#if TEST_STD_VER > 11 + (void) std::equal(it, it, it, it); + (void) std::equal(it, it, it, it, pred); +#endif + (void) std::fill_n(it, 0, 0); + (void) std::fill(it, it, 0); + (void) std::find_end(it, it, it, it); + (void) std::find_end(it, it, it, it, pred); + (void) std::find_first_of(it, it, it, it); + (void) std::find_first_of(it, it, it, it, pred); + (void) std::find_if_not(it, it, pred); + (void) std::find_if(it, it, pred); + (void) std::find(it, it, 0); +#if TEST_STD_VER > 14 + (void) std::for_each_n(it, 0, pred); +#endif + (void) std::for_each(it, it, pred); + (void) std::generate_n(it, 0, pred); + (void) std::generate(it, it, pred); + (void) std::includes(it, it, it, it); + (void) std::includes(it, it, it, it, pred); + (void) std::inplace_merge(it, it, it); + (void) std::inplace_merge(it, it, it, pred); + (void) std::is_heap_until(it, it); + (void) std::is_heap_until(it, it, pred); + (void) std::is_heap(it, it); + (void) std::is_heap(it, it, pred); + (void) std::is_partitioned(it, it, pred); + (void) std::is_permutation(it, it, it); + (void) std::is_permutation(it, it, it, pred); +#if TEST_STD_VER > 11 + (void) std::is_permutation(it, it, it, it); + (void) std::is_permutation(it, it, it, it, pred); +#endif + (void) std::is_sorted_until(it, it); + (void) std::is_sorted_until(it, it, pred); + (void) std::is_sorted(it, it); + (void) std::is_sorted(it, it, pred); + (void) std::lexicographical_compare(it, it, it, it); + (void) std::lexicographical_compare(it, it, it, it, pred); +#if TEST_STD_VER > 17 + (void)std::lexicographical_compare_three_way(it, it, it, it); + (void)std::lexicographical_compare_three_way(it, it, it, it, std::compare_three_way()); +#endif + (void) std::lower_bound(it, it, 0); + (void) std::lower_bound(it, it, 0, pred); + (void) std::make_heap(it, it); + (void) std::make_heap(it, it, pred); + (void) std::max_element(it, it); + (void) std::max_element(it, it, pred); + (void) std::merge(it, it, it, it, it); + (void) std::merge(it, it, it, it, it, pred); + (void) std::min_element(it, it); + (void) std::min_element(it, it, pred); + (void) std::minmax_element(it, it); + (void) std::minmax_element(it, it, pred); + (void) std::mismatch(it, it, it); + (void) std::mismatch(it, it, it, pred); + (void) std::move_backward(it, it, it); + (void) std::move(it, it, it); + (void) std::next_permutation(it, it); + (void) std::next_permutation(it, it, pred); + (void) std::none_of(it, it, pred); + (void) std::nth_element(it, it, it); + (void) std::nth_element(it, it, it, pred); + (void) std::partial_sort_copy(it, it, it, it); + (void) std::partial_sort_copy(it, it, it, it, pred); + (void) std::partial_sort(it, it, it); + (void) std::partial_sort(it, it, it, pred); + (void) std::partition_copy(it, it, it, it, pred); + (void) std::partition_point(it, it, pred); + (void) std::partition(it, it, pred); + (void) std::pop_heap(it, it); + (void) std::pop_heap(it, it, pred); + (void) std::prev_permutation(it, it); + (void) std::prev_permutation(it, it, pred); + (void) std::push_heap(it, it); + (void) std::push_heap(it, it, pred); + (void) std::remove_copy_if(it, it, it, pred); + (void) std::remove_copy(it, it, it, 0); + (void) std::remove_if(it, it, pred); + (void) std::remove(it, it, 0); + (void) std::replace_copy_if(it, it, it, pred, 0); + (void) std::replace_copy(it, it, it, 0, 0); + (void) std::replace_if(it, it, pred, 0); + (void) std::replace(it, it, 0, 0); + (void) std::reverse_copy(it, it, it); + (void) std::reverse(it, it); + (void) std::rotate_copy(it, it, it, it); + (void) std::rotate(it, it, it); +#if TEST_STD_VER > 14 + (void) std::sample(it, it, it, 0, rng); +#endif + (void) std::search(it, it, it, it); + (void) std::search(it, it, it, it, pred); +#if TEST_STD_VER > 14 + (void) std::search(it, it, std::default_searcher>(it, it)); +#endif + (void) std::set_difference(it, it, it, it, it); + (void) std::set_difference(it, it, it, it, it, pred); + (void) std::set_intersection(it, it, it, it, it); + (void) std::set_intersection(it, it, it, it, it, pred); + (void) std::set_symmetric_difference(it, it, it, it, it); + (void) std::set_symmetric_difference(it, it, it, it, it, pred); + (void) std::set_union(it, it, it, it, it); + (void) std::set_union(it, it, it, it, it, pred); +#if TEST_STD_VER > 17 + (void) std::shift_left(it, it, 0); + (void) std::shift_right(it, it, 0); +#endif + (void) std::shuffle(it, it, rng); + (void) std::sort_heap(it, it); + (void) std::sort_heap(it, it, pred); + (void) std::sort(it, it); + (void) std::sort(it, it, pred); + (void) std::stable_partition(it, it, pred); + (void) std::stable_sort(it, it); + (void) std::swap_ranges(it, it, it); + (void) std::transform(it, it, it, pred); + (void) std::transform(it, it, it, it, pred); + (void) std::unique_copy(it, it, it); + (void) std::unique(it, it); + (void) std::upper_bound(it, it, 0); +} diff --git a/libcxx/test/libcxx-03/algorithms/robust_against_using_non_transparent_comparators.pass.cpp b/libcxx/test/libcxx-03/algorithms/robust_against_using_non_transparent_comparators.pass.cpp new file mode 100644 index 0000000000000..39870ebe7ff02 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/robust_against_using_non_transparent_comparators.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +#include "test_macros.h" + +template +struct Iterator { + using value_type = T; + using pointer = value_type*; + using difference_type = std::ptrdiff_t; + using iterator_category = std::forward_iterator_tag; + struct reference { + T* ptr_; + + reference(T* ptr) : ptr_(ptr) {} + + friend bool operator<(reference a, reference b) { return *a.ptr_ < *b.ptr_; } + friend bool operator<(reference a, value_type const& b) { return *a.ptr_ < b; } + friend bool operator<(value_type const& a, reference b) { return a < *b.ptr_; } + + operator T&() const; + }; + + Iterator& operator++() { + ptr_++; + return *this; + } + + Iterator operator++(int) { + Iterator tmp = *this; + ptr_++; + return tmp; + } + + friend bool operator==(Iterator const& a, Iterator const& b) { return a.ptr_ == b.ptr_; } + friend bool operator!=(Iterator const& a, Iterator const& b) { return !(a == b); } + + reference operator*() const { return reference(ptr_); } + + explicit Iterator(T* ptr) : ptr_(ptr) {} + Iterator() = default; + Iterator(Iterator const&) = default; + Iterator(Iterator&&) = default; + + Iterator& operator=(Iterator const&) = default; + Iterator& operator=(Iterator&&) = default; + +private: + T* ptr_; +}; + +int main(int, char**) { + int array[5] = {1, 2, 3, 4, 5}; + Iterator first(array); + Iterator middle(array + 3); + Iterator last(array + 5); + (void)std::binary_search(first, last, 3); + (void)std::equal_range(first, last, 3); + (void)std::includes(first, last, first, last); + (void)std::is_sorted_until(first, last); + (void)std::is_sorted(first, last); + (void)std::lexicographical_compare(first, last, first, last); + (void)std::lower_bound(first, last, 3); + (void)std::max_element(first, last); + (void)std::min_element(first, last); + (void)std::minmax_element(first, last); + (void)std::upper_bound(first, last, 3); + + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/sort_stability.pass.cpp b/libcxx/test/libcxx-03/algorithms/sort_stability.pass.cpp new file mode 100644 index 0000000000000..712f12c255935 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/sort_stability.pass.cpp @@ -0,0 +1,100 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// Test std::sort stability randomization + +// UNSUPPORTED: c++03 +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +struct EqualType { + int value = 0; + constexpr bool operator<(const EqualType&) const { return false; } +}; + +std::vector deterministic() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1); + } + std::less comp; + std::__sort_dispatch(v.begin(), v.end(), comp); + return v; +} + +void test_randomization() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1); + } + auto deterministic_v = deterministic(); + std::sort(v.begin(), v.end()); + bool all_equal = true; + for (int i = 0; i < kSize; ++i) { + if (v[i].value != deterministic_v[i].value) { + all_equal = false; + } + } + assert(!all_equal); +} + +void test_same() { + static constexpr int kSize = 100; + std::vector v; + v.resize(kSize); + for (int i = 0; i < kSize; ++i) { + v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1); + } + auto snapshot_v = v; + auto snapshot_custom_v = v; + std::sort(v.begin(), v.end()); + std::sort(snapshot_v.begin(), snapshot_v.end()); + std::sort(snapshot_custom_v.begin(), snapshot_custom_v.end(), + [](const EqualType&, const EqualType&) { return false; }); + bool all_equal = true; + for (int i = 0; i < kSize; ++i) { + if (v[i].value != snapshot_v[i].value || v[i].value != snapshot_custom_v[i].value) { + all_equal = false; + } + } + assert(all_equal); +} + +#if TEST_STD_VER > 17 +constexpr bool test_constexpr() { + std::array v; + for (int i = 9; i >= 0; --i) { + v[9 - i].value = i; + } + std::sort(v.begin(), v.end()); + return std::is_sorted(v.begin(), v.end()); +} +#endif + +int main(int, char**) { + test_randomization(); + test_same(); +#if TEST_STD_VER > 17 + static_assert(test_constexpr(), ""); +#endif + return 0; +} diff --git a/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp new file mode 100644 index 0000000000000..9c488c255465f --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_iterator.compile.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// template +// concept __nothrow_forward_iterator; + +#include + +#include "test_iterators.h" + +static_assert(std::ranges::__nothrow_forward_iterator>); +static_assert(std::forward_iterator>); +static_assert(!std::ranges::__nothrow_forward_iterator>); + +constexpr bool forward_subsumes_input(std::ranges::__nothrow_forward_iterator auto) { + return true; +} +constexpr bool forward_subsumes_input(std::ranges::__nothrow_input_iterator auto); + +static_assert(forward_subsumes_input("foo")); diff --git a/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp new file mode 100644 index 0000000000000..2ddfdf66362e1 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// template +// concept __nothrow_forward_range; + +#include + +#include "test_iterators.h" +#include "test_range.h" + +static_assert(std::ranges::__nothrow_forward_range>); +static_assert(!std::ranges::__nothrow_forward_range>); +static_assert(std::ranges::forward_range>); +static_assert(!std::ranges::__nothrow_forward_range>); + +constexpr bool forward_subsumes_input(std::ranges::__nothrow_forward_range auto&&) { + return true; +} +constexpr bool forward_subsumes_input(std::ranges::__nothrow_input_range auto&&); + +static_assert(forward_subsumes_input("foo")); diff --git a/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_iterator.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_iterator.compile.pass.cpp new file mode 100644 index 0000000000000..2da3f4297af70 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_iterator.compile.pass.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, c++11, c++14, c++17 + +// template +// concept __nothrow_input_iterator; + +#include + +#include "test_iterators.h" + +struct InputProxyIterator { + using value_type = int; + using difference_type = int; + InputProxyIterator& operator++(); + InputProxyIterator operator++(int); + + int operator*() const; +}; + +static_assert(std::ranges::__nothrow_input_iterator>); +static_assert(!std::ranges::__nothrow_input_iterator>); +static_assert(std::input_iterator); +static_assert(!std::ranges::__nothrow_input_iterator); diff --git a/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_range.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_range.compile.pass.cpp new file mode 100644 index 0000000000000..2f851c4b83754 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_input_range.compile.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// template +// concept __nothrow_input_range; + +#include + +#include "test_iterators.h" +#include "test_range.h" + +// Has to be a template to work with `test_range`. +template +struct InputProxyIterator { + using value_type = int; + using difference_type = int; + InputProxyIterator& operator++(); + InputProxyIterator operator++(int); + + int operator*() const; +}; + +static_assert(std::ranges::__nothrow_input_range>); +static_assert(std::ranges::input_range>); +static_assert(!std::ranges::__nothrow_input_range>); diff --git a/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp new file mode 100644 index 0000000000000..a605095c8becf --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// template +// concept __nothrow_sentinel_for; + +#include +#include + +static_assert(std::ranges::__nothrow_sentinel_for); +static_assert(!std::ranges::__nothrow_sentinel_for); + +// Because `__nothrow_sentinel_for` is essentially an alias for `sentinel_for`, +// the two concepts should subsume each other. + +constexpr bool ntsf_subsumes_sf(std::ranges::__nothrow_sentinel_for auto) requires true { + return true; +} +constexpr bool ntsf_subsumes_sf(std::sentinel_for auto); + +static_assert(ntsf_subsumes_sf("foo")); + +constexpr bool sf_subsumes_ntsf(std::sentinel_for auto) requires true { + return true; +} +constexpr bool sf_subsumes_ntsf(std::ranges::__nothrow_sentinel_for auto); + +static_assert(sf_subsumes_ntsf("foo")); diff --git a/libcxx/test/libcxx-03/algorithms/vectorization.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/vectorization.compile.pass.cpp new file mode 100644 index 0000000000000..733a147b80cc3 --- /dev/null +++ b/libcxx/test/libcxx-03/algorithms/vectorization.compile.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// We don't know how to vectorize algorithms on GCC +// XFAIL: gcc + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +// We don't vectorize algorithms before C++14 +// XFAIL: c++03, c++11 + +// We don't vectorize algorithms on AIX right now. +// XFAIL: target={{.+}}-aix{{.*}} + +// We don't vectorize on AppleClang 15 since that apparently breaks std::mismatch +// XFAIL: apple-clang-15 + +// This test ensures that we enable the vectorization of algorithms on the expected +// platforms. + +#include + +#ifndef _LIBCPP_VECTORIZE_ALGORITHMS +# error It looks like the test needs to be updated since _LIBCPP_VECTORIZE_ALGORITHMS isn't defined anymore +#endif + +#if !_LIBCPP_VECTORIZE_ALGORITHMS +# error Algorithms should be vectorized on this platform +#endif diff --git a/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp new file mode 100644 index 0000000000000..69154c3f7eaff --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This compile-time customization requires cross-file macros, which doesn't work with modules. +// UNSUPPORTED: clang-modules-build + +// Make sure that we can customize the verbose termination function at compile-time by +// defining _LIBCPP_VERBOSE_ABORT ourselves. Note that this does not have any +// deployment target requirements. + +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_VERBOSE_ABORT(...)=my_abort(__VA_ARGS__) + +#include + +void my_abort(char const*, ...) { + std::exit(EXIT_SUCCESS); +} + +int main(int, char**) { + _LIBCPP_VERBOSE_ABORT("%s", "message"); + return EXIT_FAILURE; +} diff --git a/libcxx/test/libcxx-03/assertions/customize_verbose_abort.link-time.pass.cpp b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.link-time.pass.cpp new file mode 100644 index 0000000000000..390c6b6db190d --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.link-time.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Test that we can set a custom verbose termination function at link-time. + +// We flag uses of the verbose termination function in older dylibs at compile-time to avoid runtime +// failures when back-deploying. +// XFAIL: availability-verbose_abort-missing + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +#include <__verbose_abort> +#include + +void std::__libcpp_verbose_abort(char const*, ...) _NOEXCEPT { std::exit(EXIT_SUCCESS); } + +int main(int, char**) { + std::__libcpp_verbose_abort("%s", "message"); + return EXIT_FAILURE; +} diff --git a/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp b/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp new file mode 100644 index 0000000000000..803868b757794 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Test that the default verbose termination function aborts the program. +// XFAIL: availability-verbose_abort-missing + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +#include <__verbose_abort> +#include +#include + +void signal_handler(int signal) { + if (signal == SIGABRT) + std::_Exit(EXIT_SUCCESS); + std::_Exit(EXIT_FAILURE); +} + +int main(int, char**) { + if (std::signal(SIGABRT, signal_handler) != SIG_ERR) + std::__libcpp_verbose_abort("%s", "foo"); + return EXIT_FAILURE; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/debug.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/debug.pass.cpp new file mode 100644 index 0000000000000..ea9770b0b2fbc --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/debug.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that assertions trigger without the user having to do anything when the debug mode has been enabled +// by default. + +// REQUIRES: libcpp-hardening-mode=debug +// `check_assertion.h` is only available starting from C++11. +// UNSUPPORTED: c++03 +// `check_assertion.h` requires Unix headers. +// REQUIRES: has-unix-headers + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Should fire"); }(), "Should fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/extensive.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/extensive.pass.cpp new file mode 100644 index 0000000000000..5743f95e472d7 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/extensive.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that assertions trigger without the user having to do anything when the extensive hardening mode +// has been enabled by default. + +// REQUIRES: libcpp-hardening-mode=extensive +// `check_assertion.h` is only available starting from C++11. +// UNSUPPORTED: c++03 +// `check_assertion.h` requires Unix headers. +// REQUIRES: has-unix-headers + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Should fire"); }(), "Should fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/fast.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/fast.pass.cpp new file mode 100644 index 0000000000000..85181859fdad0 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/fast.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that assertions trigger without the user having to do anything when the fast hardening mode has +// been enabled by default. + +// REQUIRES: libcpp-hardening-mode=fast +// `check_assertion.h` is only available starting from C++11. +// UNSUPPORTED: c++03 +// `check_assertion.h` requires Unix headers. +// REQUIRES: has-unix-headers + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Should fire"); }(), "Should fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp b/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp new file mode 100644 index 0000000000000..751ff7247445f --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test verifies that setting the hardening mode to a value that's not part of the predefined constants triggers +// a compile-time error. + +// Modules build produces a different error ("Could not build module 'std'"). +// UNSUPPORTED: clang-modules-build +// REQUIRES: verify-support + +// Note that GCC doesn't support `-Wno-macro-redefined`. +// RUN: %{verify} -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=42 +// Make sure that common cases of misuse produce readable errors. We deliberately disallow setting the hardening mode as +// if it were a boolean flag. +// RUN: %{verify} -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=0 +// RUN: %{verify} -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=1 +// RUN: %{verify} -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE + +#include + +// expected-error@*:* {{_LIBCPP_HARDENING_MODE must be set to one of the following values: _LIBCPP_HARDENING_MODE_NONE, _LIBCPP_HARDENING_MODE_FAST, _LIBCPP_HARDENING_MODE_EXTENSIVE, _LIBCPP_HARDENING_MODE_DEBUG}} diff --git a/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp new file mode 100644 index 0000000000000..b64290a31a129 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test checks that if no hardening mode is defined (i.e., in the unchecked mode), by default assertions aren't +// triggered. + +// REQUIRES: libcpp-hardening-mode=none + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +#include <__assert> +#include + +bool executed_condition = false; +bool f() { + executed_condition = true; + return false; +} + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Also should not fire"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(f(), "Should not execute anything"); + assert(!executed_condition); // Really make sure we did not execute anything. + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/override_with_debug_mode.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/override_with_debug_mode.pass.cpp new file mode 100644 index 0000000000000..02565d0b6a176 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/override_with_debug_mode.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that we can override any hardening mode with the debug mode on a per-TU basis. + +// `check_assertion.h` is only available starting from C++11 and requires Unix headers and regex support. +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, no-localization +// The ability to set a custom abort message is required to compare the assertion message. +// XFAIL: availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_INTERNAL(true, "Should not fire"); + TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_INTERNAL(false, "Debug-mode assertions should fire"); }(), + "Debug-mode assertions should fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/override_with_extensive_mode.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/override_with_extensive_mode.pass.cpp new file mode 100644 index 0000000000000..74fe70feb077c --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/override_with_extensive_mode.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that we can override any hardening mode with the extensive hardening mode on a per-TU basis. + +// `check_assertion.h` is only available starting from C++11 and requires Unix headers and regex support. +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, no-localization +// The ability to set a custom abort message is required to compare the assertion message (which only happens in the +// debug mode). +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// HWASAN replaces TRAP with abort or error exit code. +// XFAIL: hwasan +// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(true, "Should not fire"); + TEST_LIBCPP_ASSERT_FAILURE( + [] { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(false, "Extensive-mode assertions should fire"); }(), + "Extensive-mode assertions should fire"); + _LIBCPP_ASSERT_INTERNAL(false, "Debug-mode assertions should not fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/override_with_fast_mode.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/override_with_fast_mode.pass.cpp new file mode 100644 index 0000000000000..f243897a986b0 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/override_with_fast_mode.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that we can override any hardening mode with the fast mode on a per-TU basis. + +// `check_assertion.h` is only available starting from C++11 and requires Unix headers and regex support. +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, no-localization +// The ability to set a custom abort message is required to compare the assertion message (which only happens in the +// debug mode). +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// HWASAN replaces TRAP with abort or error exit code. +// XFAIL: hwasan +// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Fast-mode assertions should fire"); }(), + "Fast-mode assertions should fire"); + _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(false, "Extensive-mode assertions should not fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/modes/override_with_unchecked_mode.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/override_with_unchecked_mode.pass.cpp new file mode 100644 index 0000000000000..0922556c8dc01 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/modes/override_with_unchecked_mode.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that we can override any hardening mode with the unchecked mode on a per-TU basis. + +// `check_assertion.h` is only available starting from C++11 and requires Unix headers and regex support. +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, no-localization +// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE + +#include +#include "check_assertion.h" + +int main(int, char**) { + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire"); + _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Also should not fire"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp b/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp new file mode 100644 index 0000000000000..474edc9dc0833 --- /dev/null +++ b/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Make sure that `_LIBCPP_ASSERT` and `_LIBCPP_ASSUME` are each a single expression. +// This is useful so we can use them in places that require an expression, such as +// in a constructor initializer list. + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +#include <__assert> +#include + +void f() { + int i = (_LIBCPP_ASSERT(true, "message"), 3); + assert(i == 3); + return _LIBCPP_ASSERT(true, "message"); +} + +void g() { + int i = (_LIBCPP_ASSUME(true), 3); + assert(i == 3); + return _LIBCPP_ASSUME(true); +} + +int main(int, char**) { + f(); + g(); + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.align/align.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.align/align.pass.cpp new file mode 100644 index 0000000000000..5990fc411e504 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.align/align.pass.cpp @@ -0,0 +1,113 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// REQUIRES: has-1024-bit-atomics +// ADDITIONAL_COMPILE_FLAGS: -Wno-psabi +// ... since C++20 std::__atomic_base initializes, so we get a warning about an +// ABI change for vector variants since the constructor code for that is +// different if one were to compile with architecture-specific vector +// extensions enabled. +// This however isn't ABI breaking as it was impossible for any code to trigger +// this without using libc++ internals. + +// GCC currently fails because it needs -fabi-version=6 to fix mangling of +// std::atomic when used with __attribute__((vector(X))). +// XFAIL: gcc + +// This fails on PowerPC, as the LLIArr2 and Padding structs do not have +// adequate alignment, despite these types returning true for the query of +// being lock-free. This is an issue that occurs when linking in the +// PowerPC GNU libatomic library into the test. +// XFAIL: target=powerpc{{.*}}le-unknown-linux-gnu + +// + +// Verify that the content of atomic is properly aligned if the type is +// lock-free. This can't be observed through the atomic API. It is +// nonetheless required for correctness of the implementation: lock-free implies +// that ISA instructions are used, and these instructions assume "suitable +// alignment". Supported architectures all require natural alignment for +// lock-freedom (e.g. load-linked / store-conditional, or cmpxchg). + +#include +#include +#include + +template +struct atomic_test : public std::__atomic_base { + atomic_test() { + if (this->is_lock_free()) { + using AtomicImpl = decltype(this->__a_); + assert(alignof(AtomicImpl) >= sizeof(AtomicImpl) && + "expected natural alignment for lock-free type"); + } + } +}; + +int main(int, char**) { + +// structs and unions can't be defined in the template invocation. +// Work around this with a typedef. +#define CHECK_ALIGNMENT(T) \ + do { \ + typedef T type; \ + atomic_test t; \ + } while (0) + + CHECK_ALIGNMENT(bool); + CHECK_ALIGNMENT(char); + CHECK_ALIGNMENT(signed char); + CHECK_ALIGNMENT(unsigned char); + CHECK_ALIGNMENT(char16_t); + CHECK_ALIGNMENT(char32_t); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + CHECK_ALIGNMENT(wchar_t); +#endif + CHECK_ALIGNMENT(short); + CHECK_ALIGNMENT(unsigned short); + CHECK_ALIGNMENT(int); + CHECK_ALIGNMENT(unsigned int); + CHECK_ALIGNMENT(long); + CHECK_ALIGNMENT(unsigned long); + CHECK_ALIGNMENT(long long); + CHECK_ALIGNMENT(unsigned long long); + CHECK_ALIGNMENT(std::nullptr_t); + CHECK_ALIGNMENT(void *); + CHECK_ALIGNMENT(float); + CHECK_ALIGNMENT(double); + CHECK_ALIGNMENT(long double); + CHECK_ALIGNMENT(int __attribute__((vector_size(1 * sizeof(int))))); + CHECK_ALIGNMENT(int __attribute__((vector_size(2 * sizeof(int))))); + CHECK_ALIGNMENT(int __attribute__((vector_size(4 * sizeof(int))))); + CHECK_ALIGNMENT(int __attribute__((vector_size(16 * sizeof(int))))); + CHECK_ALIGNMENT(int __attribute__((vector_size(32 * sizeof(int))))); + CHECK_ALIGNMENT(float __attribute__((vector_size(1 * sizeof(float))))); + CHECK_ALIGNMENT(float __attribute__((vector_size(2 * sizeof(float))))); + CHECK_ALIGNMENT(float __attribute__((vector_size(4 * sizeof(float))))); + CHECK_ALIGNMENT(float __attribute__((vector_size(16 * sizeof(float))))); + CHECK_ALIGNMENT(float __attribute__((vector_size(32 * sizeof(float))))); + CHECK_ALIGNMENT(double __attribute__((vector_size(1 * sizeof(double))))); + CHECK_ALIGNMENT(double __attribute__((vector_size(2 * sizeof(double))))); + CHECK_ALIGNMENT(double __attribute__((vector_size(4 * sizeof(double))))); + CHECK_ALIGNMENT(double __attribute__((vector_size(16 * sizeof(double))))); + CHECK_ALIGNMENT(double __attribute__((vector_size(32 * sizeof(double))))); + CHECK_ALIGNMENT(struct Empty {}); + CHECK_ALIGNMENT(struct OneInt { int i; }); + CHECK_ALIGNMENT(struct IntArr2 { int i[2]; }); + CHECK_ALIGNMENT(struct FloatArr3 { float i[3]; }); + CHECK_ALIGNMENT(struct LLIArr2 { long long int i[2]; }); + CHECK_ALIGNMENT(struct LLIArr4 { long long int i[4]; }); + CHECK_ALIGNMENT(struct LLIArr8 { long long int i[8]; }); + CHECK_ALIGNMENT(struct LLIArr16 { long long int i[16]; }); + CHECK_ALIGNMENT(struct Padding { char c; /* padding */ long long int i; }); + CHECK_ALIGNMENT(union IntFloat { int i; float f; }); + CHECK_ALIGNMENT(enum class StrongEnum { foo }); + + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.flag/init_bool.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.flag/init_bool.pass.cpp new file mode 100644 index 0000000000000..7678775527419 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.flag/init_bool.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// struct atomic_flag + +// TESTING EXTENSION atomic_flag(bool) + +#include +#include + +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +// Ensure that static initialization happens; this is PR#37226 +extern std::atomic_flag global; +struct X { X() { global.test_and_set(); }}; +X x; +std::atomic_flag global{false}; +#endif + +int main(int, char**) +{ +#if TEST_STD_VER >= 11 + assert(global.test_and_set() == 1); +#endif + { + std::atomic_flag f(false); + assert(f.test_and_set() == 0); + } + { + std::atomic_flag f(true); + assert(f.test_and_set() == 1); + } + + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp new file mode 100644 index 0000000000000..5379ef8787d56 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// This test ensures that std::memory_order has the same size under all +// standard versions to make sure we're not breaking the ABI. This is +// relevant because std::memory_order is a scoped enumeration in C++20, +// but an unscoped enumeration pre-C++20. +// +// See PR40977 for details. + +#include +#include + +#include "test_macros.h" + + +enum cpp17_memory_order { + cpp17_memory_order_relaxed, cpp17_memory_order_consume, cpp17_memory_order_acquire, + cpp17_memory_order_release, cpp17_memory_order_acq_rel, cpp17_memory_order_seq_cst +}; + +static_assert((std::is_same::type, + std::underlying_type::type>::value), + "std::memory_order should have the same underlying type as a corresponding " + "unscoped enumeration would. Otherwise, our ABI changes from C++17 to C++20."); + +int main(int, char**) { + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp new file mode 100644 index 0000000000000..92f6a622c329c --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_strong.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none || libcpp-hardening-mode=fast +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -Wno-user-defined-warnings + +// + +// bool compare_exchange_strong(T& expected, T desired, memory_order success, memory_order failure) const noexcept; +// +// Preconditions: failure is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +#include "atomic_helpers.h" +#include "check_assertion.h" + +template +struct TestCompareExchangeStrongInvalidMemoryOrder { + void operator()() const { + { // no assertion should trigger here + T x(T(1)); + std::atomic_ref const a(x); + T t(T(2)); + a.compare_exchange_strong(t, T(3), std::memory_order_relaxed, std::memory_order_relaxed); + } + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + T t(T(2)); + a.compare_exchange_strong(t, T(3), std::memory_order_relaxed, std::memory_order_release); + }()), + "atomic_ref: failure memory order argument to strong atomic compare-and-exchange operation is invalid"); + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + T t(T(2)); + a.compare_exchange_strong(t, T(3), std::memory_order_relaxed, std::memory_order_acq_rel); + }()), + "atomic_ref: failure memory order argument to strong atomic compare-and-exchange operation is invalid"); + } +}; + +int main(int, char**) { + TestEachAtomicType()(); + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp new file mode 100644 index 0000000000000..3bee003b2143f --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.compare_exchange_weak.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none || libcpp-hardening-mode=fast +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -Wno-user-defined-warnings + +// + +// bool compare_exchange_weak(T& expected, T desired, memory_order success, memory_order failure) const noexcept; +// +// Preconditions: failure is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +#include "atomic_helpers.h" +#include "check_assertion.h" + +template +struct TestCompareExchangeWeakInvalidMemoryOrder { + void operator()() const { + { // no assertion should trigger here + T x(T(1)); + std::atomic_ref const a(x); + T t(T(2)); + a.compare_exchange_weak(t, T(3), std::memory_order_relaxed, std::memory_order_relaxed); + } + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + T t(T(2)); + a.compare_exchange_weak(t, T(3), std::memory_order_relaxed, std::memory_order_release); + }()), + "atomic_ref: failure memory order argument to weak atomic compare-and-exchange operation is invalid"); + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + T t(T(2)); + a.compare_exchange_weak(t, T(3), std::memory_order_relaxed, std::memory_order_acq_rel); + }()), + "atomic_ref: failure memory order argument to weak atomic compare-and-exchange operation is invalid"); + } +}; + +int main(int, char**) { + TestEachAtomicType()(); + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/assert.ctor.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.ctor.pass.cpp new file mode 100644 index 0000000000000..3d4700406984c --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.ctor.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none || libcpp-hardening-mode=fast +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +// + +// atomic_ref(T& obj); +// +// Preconditions: The referenced object is aligned to required_alignment. + +#include +#include + +#include "check_assertion.h" + +int main(int, char**) { + { // no assertion should trigger here + alignas(float) std::byte c[sizeof(float)]; + float* f = new (c) float(3.14f); + [[maybe_unused]] std::atomic_ref r(*f); + } + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + alignas(float) std::byte c[2 * sizeof(float)]; // intentionally larger + float* f = new (c + 1) float(3.14f); // intentionally misaligned + [[maybe_unused]] std::atomic_ref r(*f); + }()), + "atomic_ref ctor: referenced object must be aligned to required_alignment"); + + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/assert.load.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.load.pass.cpp new file mode 100644 index 0000000000000..504d135c4f3d7 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.load.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none || libcpp-hardening-mode=fast +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -Wno-user-defined-warnings + +// + +// T load(memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +#include "atomic_helpers.h" +#include "check_assertion.h" + +template +struct TestLoadInvalidMemoryOrder { + void operator()() const { + { // no assertion should trigger here + T x(T(1)); + std::atomic_ref const a(x); + (void)a.load(std::memory_order_relaxed); + } + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + (void)a.load(std::memory_order_release); + }()), + "atomic_ref: memory order argument to atomic load operation is invalid"); + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + (void)a.load(std::memory_order_acq_rel); + }()), + "atomic_ref: memory order argument to atomic load operation is invalid"); + } +}; + +int main(int, char**) { + TestEachAtomicType()(); + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/assert.store.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.store.pass.cpp new file mode 100644 index 0000000000000..1afa42528e14f --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.store.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none || libcpp-hardening-mode=fast +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -Wno-user-defined-warnings + +// + +// void store(T desired, memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::release, or memory_order::seq_cst. + +#include + +#include "atomic_helpers.h" +#include "check_assertion.h" + +template +struct TestStoreInvalidMemoryOrder { + void operator()() const { + { // no assertion should trigger here + T x(T(1)); + std::atomic_ref const a(x); + a.store(T(2), std::memory_order_relaxed); + } + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + a.store(T(2), std::memory_order_consume); + }()), + "atomic_ref: memory order argument to atomic store operation is invalid"); + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + a.store(T(2), std::memory_order_acquire); + }()), + "atomic_ref: memory order argument to atomic store operation is invalid"); + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + a.store(T(2), std::memory_order_acq_rel); + }()), + "atomic_ref: memory order argument to atomic store operation is invalid"); + } +}; + +int main(int, char**) { + TestEachAtomicType()(); + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/assert.wait.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.wait.pass.cpp new file mode 100644 index 0000000000000..39178d2393be2 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/assert.wait.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: has-unix-headers +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-hardening-mode=none || libcpp-hardening-mode=fast +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing +// ADDITIONAL_COMPILE_FLAGS: -Wno-user-defined-warnings + +// + +// void wait(T old, memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +#include "atomic_helpers.h" +#include "check_assertion.h" + +template +struct TestWaitInvalidMemoryOrder { + void operator()() const { + { // no assertion should trigger here + T x(T(1)); + std::atomic_ref const a(x); + a.wait(T(2), std::memory_order_relaxed); + } + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + a.wait(T(2), std::memory_order_release); + }()), + "atomic_ref: memory order argument to atomic wait operation is invalid"); + + TEST_LIBCPP_ASSERT_FAILURE( + ([] { + T x(T(1)); + std::atomic_ref const a(x); + a.wait(T(2), std::memory_order_acq_rel); + }()), + "atomic_ref: memory order argument to atomic wait operation is invalid"); + } +}; + +int main(int, char**) { + TestEachAtomicType()(); + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_strong.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_strong.verify.cpp new file mode 100644 index 0000000000000..427c82dbd0af2 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_strong.verify.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// bool compare_exchange_strong(T& expected, T desired, memory_order success, +// memory_order failure) const noexcept; +// +// Preconditions: failure is memory_order::relaxed, memory_order::consume, +// memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + T expected(T(2)); + T const desired(T(3)); + std::memory_order const success = std::memory_order_relaxed; + // clang-format off + a.compare_exchange_strong(expected, desired, success, std::memory_order_relaxed); + a.compare_exchange_strong(expected, desired, success, std::memory_order_consume); + a.compare_exchange_strong(expected, desired, success, std::memory_order_acquire); + a.compare_exchange_strong(expected, desired, success, std::memory_order_seq_cst); + a.compare_exchange_strong(expected, desired, success, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + a.compare_exchange_strong(expected, desired, success, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_weak.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_weak.verify.cpp new file mode 100644 index 0000000000000..6a1046074dd26 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/compare_exchange_weak.verify.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// bool compare_exchange_weak(T& expected, T desired, memory_order success, +// memory_order failure) const noexcept; +// +// Preconditions: failure is memory_order::relaxed, memory_order::consume, +// memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(42)); + std::atomic_ref const a(x); + + T expected(T(2)); + T const desired(T(3)); + std::memory_order const success = std::memory_order_relaxed; + // clang-format off + a.compare_exchange_weak(expected, desired, success, std::memory_order_relaxed); + a.compare_exchange_weak(expected, desired, success, std::memory_order_consume); + a.compare_exchange_weak(expected, desired, success, std::memory_order_acquire); + a.compare_exchange_weak(expected, desired, success, std::memory_order_seq_cst); + a.compare_exchange_weak(expected, desired, success, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + a.compare_exchange_weak(expected, desired, success, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/load.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/load.verify.cpp new file mode 100644 index 0000000000000..9fdecb16d9d9b --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/load.verify.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// T load(memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + // clang-format off + (void)a.load(std::memory_order_relaxed); + (void)a.load(std::memory_order_consume); + (void)a.load(std::memory_order_acquire); + (void)a.load(std::memory_order_seq_cst); + (void)a.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + (void)a.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/store.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/store.verify.cpp new file mode 100644 index 0000000000000..0be4e5ebfa2cc --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/store.verify.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// void store(T desired, memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::release, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + T const desired(T(2)); + + // clang-format off + a.store(desired, std::memory_order_relaxed); + a.store(desired, std::memory_order_release); + a.store(desired, std::memory_order_seq_cst); + a.store(desired, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + a.store(desired, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + a.store(desired, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.ref/wait.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.ref/wait.verify.cpp new file mode 100644 index 0000000000000..718e716ebdb32 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.ref/wait.verify.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// void wait(T old, memory_order order = memory_order::seq_cst) const noexcept; +// +// Preconditions: order is memory_order::relaxed, memory_order::consume, memory_order::acquire, or memory_order::seq_cst. + +#include + +void test() { + using T = int; + + T x(T(1)); + std::atomic_ref const a(x); + + T const old(T(2)); + + // clang-format off + a.wait(old, std::memory_order_relaxed); + a.wait(old, std::memory_order_consume); + a.wait(old, std::memory_order_acquire); + a.wait(old, std::memory_order_seq_cst); + a.wait(old, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + a.wait(old, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // clang-format on +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp new file mode 100644 index 0000000000000..349dc51aaa0e6 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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: no-threads +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// This test verifies that redirects to . + +// Before C++23, can be included after , but including it +// first doesn't work because its macros break . Fixing that is the point +// of the C++23 change that added to C++. Thus, this test verifies +// that can be included first. +#include +#include + +#include + +static_assert(std::is_same >::value, ""); diff --git a/libcxx/test/libcxx-03/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp new file mode 100644 index 0000000000000..a788ea32dddc8 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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: no-threads +// REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20 + +// No diagnostic gets emitted when we build with modules. +// XFAIL: clang-modules-build + +// This test ensures that we issue a reasonable diagnostic when including after +// has been included. Before C++23, this otherwise leads to obscure errors +// because may try to redefine things defined by . + +// Ignore additional weird errors that happen when the two headers are mixed. +// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error -Xclang -verify-ignore-unexpected=warning + +#include +#include + +// expected-error@*:* {{ is incompatible with before C++23.}} diff --git a/libcxx/test/libcxx-03/atomics/atomics.syn/wait.issue_85107.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.syn/wait.issue_85107.pass.cpp new file mode 100644 index 0000000000000..03eaa0e55ac6a --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.syn/wait.issue_85107.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 +// UNSUPPORTED: no-threads + +// This bug was first fixed in LLVM 19. This can't be XFAIL because +// the test is a no-op (and would XPASS) on some targets. +// UNSUPPORTED: using-built-library-before-llvm-19 + +// XFAIL: availability-synchronization_library-missing + +// This is a regression test for https://github.com/llvm/llvm-project/issues/85107, which describes +// how we were using UL_COMPARE_AND_WAIT instead of UL_COMPARE_AND_WAIT64 in the implementation of +// atomic::wait, leading to potential infinite hangs. + +#include +#include +#include + +#include "make_test_thread.h" + +int main(int, char**) { + if constexpr (sizeof(std::__cxx_contention_t) == 8 && sizeof(long) > 4) { + std::atomic done = false; + auto const timeout = std::chrono::system_clock::now() + std::chrono::seconds(600); // fail after 10 minutes + + auto timeout_thread = support::make_test_thread([&] { + while (!done) { + assert(std::chrono::system_clock::now() < timeout); // make sure we don't hang forever + } + }); + + // https://github.com/llvm/llvm-project/issues/85107 + // [libc++] atomic_wait uses UL_COMPARE_AND_WAIT when it should use UL_COMPARE_AND_WAIT64 on Darwin + constexpr std::__cxx_contention_t old_val = 0; + constexpr std::__cxx_contention_t new_val = old_val + (1ll << 32); + std::__cxx_atomic_contention_t ct(new_val); + + // This would hang forever if the bug is present, but the test will fail in a bounded amount of + // time due to the timeout above. + std::__libcpp_atomic_wait(&ct, old_val); + + done = true; + timeout_thread.join(); + } + + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp new file mode 100644 index 0000000000000..352e705151513 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 +// XFAIL: !has-64-bit-atomics + +// static constexpr bool is_always_lock_free = implementation-defined; +// bool is_lock_free() const volatile noexcept; +// bool is_lock_free() const noexcept; + +#include +#include +#include + +#include "test_macros.h" + +template +void test() { + // static constexpr bool is_always_lock_free = implementation-defined; + { + bool r = std::atomic::is_always_lock_free; + assert(r == __atomic_always_lock_free(sizeof(std::__cxx_atomic_impl), 0)); + } + + // bool is_lock_free() const volatile noexcept; + { + const volatile std::atomic a; + bool r = a.is_lock_free(); + assert(r == __cxx_atomic_is_lock_free(sizeof(std::__cxx_atomic_impl))); + } + + // bool is_lock_free() const noexcept; + { + const std::atomic a; + bool r = a.is_lock_free(); + assert(r == __cxx_atomic_is_lock_free(sizeof(std::__cxx_atomic_impl))); + } +} + +int main(int, char**) { + test(); + test(); + // TODO https://github.com/llvm/llvm-project/issues/47978 + // test(); + + return 0; +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp new file mode 100644 index 0000000000000..320ef57dcb6f9 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +// + +// template +// T* atomic_fetch_add(volatile atomic* obj, ptrdiff_t op) +// template +// T* atomic_fetch_add(atomic* obj, ptrdiff_t op); + +#include + +void void_pointer() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_add(&obj, 0); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_add(&obj, 0); + } +} + +struct Incomplete; + +void pointer_to_incomplete_type() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_add(&obj, 0); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_add(&obj, 0); + } +} + +void function_pointer() { + { + volatile std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_add(&fun, 0); + } + { + std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_add(&fun, 0); + } +} + +struct S { + void fun(int); +}; + +void member_function_pointer() { + { + volatile std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_add'}} + std::atomic_fetch_add(&fun, 0); + } + { + std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_add'}} + std::atomic_fetch_add(&fun, 0); + } +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp new file mode 100644 index 0000000000000..bdd8089feb281 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +// + +// template +// T* +// atomic_fetch_add_explicit(volatile atomic* obj, ptrdiff_t op, +// memory_order m); +// template +// T* +// atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m); + +#include + +void void_pointer() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_add_explicit(&obj, 0, std::memory_order_relaxed); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_add_explicit(&obj, 0, std::memory_order_relaxed); + } +} + +struct Incomplete; + +void pointer_to_incomplete_type() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_add_explicit(&obj, 0, std::memory_order_relaxed); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_add_explicit(&obj, 0, std::memory_order_relaxed); + } +} + +void function_pointer() { + { + volatile std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed); + } + { + std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed); + } +} + +struct S { + void fun(int); +}; + +void member_function_pointer() { + { + volatile std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_add_explicit'}} + std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed); + } + { + std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_add_explicit'}} + std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed); + } +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp new file mode 100644 index 0000000000000..2c9f89891d5be --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +// + +// template +// T* atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op) +// template +// T* atomic_fetch_sub(atomic* obj, ptrdiff_t op); + +#include + +void void_pointer() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_sub(&obj, 0); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_sub(&obj, 0); + } +} + +struct Incomplete; + +void pointer_to_incomplete_type() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_sub(&obj, 0); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_sub(&obj, 0); + } +} + +void function_pointer() { + { + volatile std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_sub(&fun, 0); + } + { + std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_sub(&fun, 0); + } +} + +struct S { + void fun(int); +}; + +void member_function_pointer() { + { + volatile std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_sub'}} + std::atomic_fetch_sub(&fun, 0); + } + { + std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_sub'}} + std::atomic_fetch_sub(&fun, 0); + } +} diff --git a/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp new file mode 100644 index 0000000000000..88c42750b608a --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + +// + +// template +// T* +// atomic_fetch_sub_explicit(volatile atomic* obj, ptrdiff_t op, +// memory_order m); +// template +// T* +// atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m); + +#include + +void void_pointer() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_sub_explicit(&obj, 0, std::memory_order_relaxed); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'void' where a complete type is required}} + std::atomic_fetch_sub_explicit(&obj, 0, std::memory_order_relaxed); + } +} + +struct Incomplete; + +void pointer_to_incomplete_type() { + { + volatile std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_sub_explicit(&obj, 0, std::memory_order_relaxed); + } + { + std::atomic obj; + // expected-error@*:* {{incomplete type 'Incomplete' where a complete type is required}} + std::atomic_fetch_sub_explicit(&obj, 0, std::memory_order_relaxed); + } +} + +void function_pointer() { + { + volatile std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed); + } + { + std::atomic fun; + // expected-error-re@*:* {{static assertion failed due to requirement '!is_function::value'{{.*}}Pointer to function isn't allowed}} + std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed); + } +} + +struct S { + void fun(int); +}; + +void member_function_pointer() { + { + volatile std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_sub_explicit'}} + std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed); + } + { + std::atomic fun; + // expected-error@*:* {{no matching function for call to 'atomic_fetch_sub_explicit'}} + std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed); + } +} diff --git a/libcxx/test/libcxx-03/atomics/bit-int.verify.cpp b/libcxx/test/libcxx-03/atomics/bit-int.verify.cpp new file mode 100644 index 0000000000000..03880a1b6215c --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/bit-int.verify.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// Make sure that `std::atomic` doesn't work with `_BitInt`. The intent is to +// disable them for now until their behavior can be designed better later. +// See https://reviews.llvm.org/D84049 for details. + +// UNSUPPORTED: c++03 + +#include + +void f() { + // expected-error@*:*1 {{_Atomic cannot be applied to integer type '_BitInt(32)'}} + std::atomic<_BitInt(32)> x(42); +} diff --git a/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp b/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp new file mode 100644 index 0000000000000..1b0b945f33700 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp @@ -0,0 +1,122 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support + +// + +// Test that invalid memory order arguments are diagnosed where possible. + +#include + +void f() { + std::atomic x(42); + volatile std::atomic& vx = x; + int val1 = 1; ((void)val1); + int val2 = 2; ((void)val2); + // load operations + { + x.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + x.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.load(std::memory_order_relaxed); + x.load(std::memory_order_consume); + x.load(std::memory_order_acquire); + x.load(std::memory_order_seq_cst); + } + { + std::atomic_load_explicit(&x, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_load_explicit(&x, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_load_explicit(&vx, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_load_explicit(&vx, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_load_explicit(&x, std::memory_order_relaxed); + std::atomic_load_explicit(&x, std::memory_order_consume); + std::atomic_load_explicit(&x, std::memory_order_acquire); + std::atomic_load_explicit(&x, std::memory_order_seq_cst); + } + // store operations + { + x.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + x.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + x.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.store(42, std::memory_order_relaxed); + x.store(42, std::memory_order_release); + x.store(42, std::memory_order_seq_cst); + } + { + std::atomic_store_explicit(&x, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&x, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&x, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&vx, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&vx, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&vx, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_store_explicit(&x, 42, std::memory_order_relaxed); + std::atomic_store_explicit(&x, 42, std::memory_order_release); + std::atomic_store_explicit(&x, 42, std::memory_order_seq_cst); + } + // compare exchange weak + { + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + // Test that the cmpxchg overload with only one memory order argument + // does not generate any diagnostics. + x.compare_exchange_weak(val1, val2, std::memory_order_release); + } + { + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + } + // compare exchange strong + { + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + // Test that the cmpxchg overload with only one memory order argument + // does not generate any diagnostics. + x.compare_exchange_strong(val1, val2, std::memory_order_release); + } + { + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + } +} diff --git a/libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.compile.pass.cpp b/libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.compile.pass.cpp new file mode 100644 index 0000000000000..6df80daf9414e --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.compile.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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: no-threads + +// This test ensures that we don't hijack the header (e.g. by providing +// an empty header) even when compiling before C++23, since some users were using the +// Clang or platform provided header before libc++ added its own. + +// On GCC, the compiler-provided is not C++ friendly, so including +// doesn't work at all if we don't use the provided by libc++ in C++23 and above. +// XFAIL: (c++11 || c++14 || c++17 || c++20) && gcc + +#include + +void f() { + atomic_int i; // just make sure the header isn't empty + (void)i; +} diff --git a/libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp b/libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp new file mode 100644 index 0000000000000..a8a99e6937f31 --- /dev/null +++ b/libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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: no-threads + +// This test verifies that DOES NOT redirect to before C++23, +// since doing so is a breaking change. Several things can break when that happens, +// because the type of _Atomic(T) changes from _Atomic(T) to std::atomic. +// +// For example, redeclarations can become invalid depending on whether they +// have been declared with in scope or not. + +// REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20 + +// On GCC, the compiler-provided is not C++ friendly, so including +// doesn't work at all if we don't use the provided by libc++ in C++23 and above. +// XFAIL: (c++11 || c++14 || c++17 || c++20) && gcc + +#include +#include +#include + +static_assert(!std::is_same<_Atomic(int), std::atomic >::value, ""); diff --git a/libcxx/test/libcxx-03/clang_modules_include.gen.py b/libcxx/test/libcxx-03/clang_modules_include.gen.py new file mode 100644 index 0000000000000..379ac22c8f47f --- /dev/null +++ b/libcxx/test/libcxx-03/clang_modules_include.gen.py @@ -0,0 +1,97 @@ +# ===----------------------------------------------------------------------===## +# +# 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 +# +# ===----------------------------------------------------------------------===## + +# Test that we can include each header in a TU while using modules. +# This is important notably because the LLDB data formatters use +# libc++ headers with modules enabled. + +# RUN: %{python} %s %{libcxx-dir}/utils + +# block Lit from interpreting a RUN/XFAIL/etc inside the generation script +# END. + +import sys +sys.path.append(sys.argv[1]) +from libcxx.header_information import ( + lit_header_restrictions, + lit_header_undeprecations, + public_headers, +) + +for header in public_headers: + print( + f"""\ +//--- {header}.compile.pass.cpp +// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only + +// Older macOS SDKs were not properly modularized, which causes issues with localization. +// This feature should instead be based on the SDK version. +// UNSUPPORTED: stdlib=system && target={{{{.+}}}}-apple-macosx13{{{{.*}}}} + +// GCC doesn't support -fcxx-modules +// UNSUPPORTED: gcc + +// The Windows headers don't appear to be compatible with modules +// UNSUPPORTED: windows +// UNSUPPORTED: buildhost=windows + +// The Android headers don't appear to be compatible with modules yet +// UNSUPPORTED: LIBCXX-ANDROID-FIXME + +// TODO: Investigate this failure +// UNSUPPORTED: LIBCXX-FREEBSD-FIXME + +// TODO: Investigate why this doesn't work on Picolibc once the locale base API is refactored +// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME + +// TODO: Fix seemingly circular inclusion or on AIX +// UNSUPPORTED: LIBCXX-AIX-FIXME + +// UNSUPPORTED: FROZEN-CXX03-HEADERS-FIXME + +{lit_header_restrictions.get(header, '')} +{lit_header_undeprecations.get(header, '')} + +#include <{header}> +""" + ) + +print( + f"""\ +//--- import_std.compile.pass.mm +// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only + +// REQUIRES: clang-modules-build + +// Older macOS SDKs were not properly modularized, which causes issues with localization. +// This feature should instead be based on the SDK version. +// UNSUPPORTED: stdlib=system && target={{{{.+}}}}-apple-macosx13{{{{.*}}}} + +// GCC doesn't support -fcxx-modules +// UNSUPPORTED: gcc + +// The Windows headers don't appear to be compatible with modules +// UNSUPPORTED: windows +// UNSUPPORTED: buildhost=windows + +// The Android headers don't appear to be compatible with modules yet +// UNSUPPORTED: LIBCXX-ANDROID-FIXME + +// TODO: Investigate this failure +// UNSUPPORTED: LIBCXX-FREEBSD-FIXME + +// TODO: Investigate why this doesn't work on Picolibc once the locale base API is refactored +// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME + +// TODO: Fix seemingly circular inclusion or on AIX +// UNSUPPORTED: LIBCXX-AIX-FIXME + +@import std; + +""" +) diff --git a/libcxx/test/libcxx-03/clang_tidy.gen.py b/libcxx/test/libcxx-03/clang_tidy.gen.py new file mode 100644 index 0000000000000..dbab2875e3126 --- /dev/null +++ b/libcxx/test/libcxx-03/clang_tidy.gen.py @@ -0,0 +1,40 @@ +# ===----------------------------------------------------------------------===## +# +# 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 +# +# ===----------------------------------------------------------------------===## + + +# Run our custom libc++ clang-tidy checks on all public headers. + +# RUN: %{python} %s %{libcxx-dir}/utils + +# block Lit from interpreting a RUN/XFAIL/etc inside the generation script +# END. + +import sys +sys.path.append(sys.argv[1]) +from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers + +for header in public_headers: + print(f"""\ +//--- {header}.sh.cpp + +// REQUIRES: has-clang-tidy + +// The frozen headers should not be updated to the latest libc++ style, so don't test. +// UNSUPPORTED: FROZEN-CXX03-HEADERS-FIXME + +// The GCC compiler flags are not always compatible with clang-tidy. +// UNSUPPORTED: gcc + +{lit_header_restrictions.get(header, '')} +{lit_header_undeprecations.get(header, '')} + +// TODO: run clang-tidy with modules enabled once they are supported +// RUN: %{{clang-tidy}} %s --warnings-as-errors=* -header-filter=.* --config-file=%{{libcxx-dir}}/.clang-tidy --load=%{{test-tools-dir}}/clang_tidy_checks/libcxx-tidy.plugin -- -Wweak-vtables %{{compile_flags}} -fno-modules + +#include <{header}> +""") diff --git a/libcxx/test/libcxx-03/clang_tidy.sh.py b/libcxx/test/libcxx-03/clang_tidy.sh.py new file mode 100644 index 0000000000000..46f281f359209 --- /dev/null +++ b/libcxx/test/libcxx-03/clang_tidy.sh.py @@ -0,0 +1,11 @@ +# ===----------------------------------------------------------------------===## +# +# 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 +# +# ===----------------------------------------------------------------------===## + +# REQUIRES: has-clang-tidy + +# RUN: %{python} %{libcxx-dir}/../clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -clang-tidy-binary %{clang-tidy} -warnings-as-errors "*" -source-filter=".*libcxx/src.*" -quiet -p %{bin-dir}/.. diff --git a/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp b/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp new file mode 100644 index 0000000000000..4958a258137a1 --- /dev/null +++ b/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// Concept helpers for the internal type traits for the fundamental types. + +// template +// concept __signed_or_unsigned_integer; + +#include <__type_traits/integer_traits.h> + +#include "test_macros.h" + +struct SomeObject {}; + +enum SomeEnum {}; + +enum class SomeScopedEnum {}; + +// Unsigned +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +#if _LIBCPP_HAS_INT128 +static_assert(std::__signed_or_unsigned_integer<__uint128_t>); +#endif +// Signed +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +static_assert(std::__signed_or_unsigned_integer); +#if _LIBCPP_HAS_INT128 +static_assert(std::__signed_or_unsigned_integer<__int128_t>); +#endif +// Non-integer +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::__signed_or_unsigned_integer); +#endif +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); +static_assert(!std::__signed_or_unsigned_integer); diff --git a/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp b/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp new file mode 100644 index 0000000000000..3fa342685770c --- /dev/null +++ b/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// Concept helpers for the internal type traits for the fundamental types. + +// template +// concept __signed_integer; + +#include <__type_traits/integer_traits.h> + +#include "test_macros.h" + +struct SomeObject {}; + +enum SomeEnum {}; + +enum class SomeScopedEnum {}; + +// Unsigned +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +#if _LIBCPP_HAS_INT128 +static_assert(!std::__signed_integer<__uint128_t>); +#endif +// Signed +static_assert(std::__signed_integer); +static_assert(std::__signed_integer); +static_assert(std::__signed_integer); +static_assert(std::__signed_integer); +static_assert(std::__signed_integer); +static_assert(std::__signed_integer); +#if _LIBCPP_HAS_INT128 +static_assert(std::__signed_integer<__int128_t>); +#endif +// Non-integer +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::__signed_integer); +#endif +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); +static_assert(!std::__signed_integer); diff --git a/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp b/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp new file mode 100644 index 0000000000000..ff60f32319171 --- /dev/null +++ b/libcxx/test/libcxx-03/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11, c++14, c++17 + +// Concept helpers for the internal type traits for the fundamental types. + +// template +// concept __unsigned_integer; + +#include <__type_traits/integer_traits.h> + +#include "test_macros.h" + +struct SomeObject {}; + +enum SomeEnum {}; + +enum class SomeScopedEnum {}; + +// Unsigned +static_assert(std::__unsigned_integer); +static_assert(std::__unsigned_integer); +static_assert(std::__unsigned_integer); +static_assert(std::__unsigned_integer); +static_assert(std::__unsigned_integer); +static_assert(std::__unsigned_integer); +#if _LIBCPP_HAS_INT128 +static_assert(std::__unsigned_integer<__uint128_t>); +#endif +// Signed +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +#if _LIBCPP_HAS_INT128 +static_assert(!std::__unsigned_integer<__int128_t>); +#endif +// Non-integer +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::__unsigned_integer); +#endif +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); +static_assert(!std::__unsigned_integer); diff --git a/libcxx/test/libcxx-03/containers/associative/map/at.abort.pass.cpp b/libcxx/test/libcxx-03/containers/associative/map/at.abort.pass.cpp new file mode 100644 index 0000000000000..d68ee5f528599 --- /dev/null +++ b/libcxx/test/libcxx-03/containers/associative/map/at.abort.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// mapped_type& at(const key_type& k); + +// Make sure we abort() when exceptions are disabled and we fetch a key that +// is not in the map. + +// REQUIRES: no-exceptions + +#include +#include +#include + +#include "test_macros.h" + +void exit_success(int) { std::_Exit(EXIT_SUCCESS); } + +int main(int, char**) { + std::signal(SIGABRT, exit_success); + std::map map; + map.at(1); + return EXIT_FAILURE; +} diff --git a/libcxx/test/libcxx-03/containers/associative/map/at.const.abort.pass.cpp b/libcxx/test/libcxx-03/containers/associative/map/at.const.abort.pass.cpp new file mode 100644 index 0000000000000..bbc8c7c4d726a --- /dev/null +++ b/libcxx/test/libcxx-03/containers/associative/map/at.const.abort.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// const mapped_type& at(const key_type& k) const; + +// Make sure we abort() when exceptions are disabled and we fetch a key that +// is not in the map. + +// REQUIRES: no-exceptions + +#include +#include +#include + +#include "test_macros.h" + +void exit_success(int) { std::_Exit(EXIT_SUCCESS); } + +int main(int, char**) { + std::signal(SIGABRT, exit_success); + std::map const map; + map.at(1); + return EXIT_FAILURE; +} diff --git a/libcxx/test/libcxx-03/containers/associative/map/find.modules.compile.pass.mm b/libcxx/test/libcxx-03/containers/associative/map/find.modules.compile.pass.mm new file mode 100644 index 0000000000000..82b1c494c9566 --- /dev/null +++ b/libcxx/test/libcxx-03/containers/associative/map/find.modules.compile.pass.mm @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Make sure that we don't get a compiler error when trying to use std::map::find +// from Objective-C++. This happened in Objective-C++ mode with modules enabled (rdar://106813461). + +// REQUIRES: objective-c++ + +#include + +void f(std::map const& map, int key) { (void)map.find(key); } diff --git a/libcxx/test/libcxx-03/containers/associative/map/scary.compile.pass.cpp b/libcxx/test/libcxx-03/containers/associative/map/scary.compile.pass.cpp new file mode 100644 index 0000000000000..89e753f854926 --- /dev/null +++ b/libcxx/test/libcxx-03/containers/associative/map/scary.compile.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// class map +// class multimap + +// Extension: SCARY/N2913 iterator compatibility between map and multimap + +#include + +#include "test_macros.h" + +void test() { + typedef std::map M1; + typedef std::multimap M2; + + ASSERT_SAME_TYPE(M1::iterator, M2::iterator); + ASSERT_SAME_TYPE(M1::const_iterator, M2::const_iterator); +} diff --git a/libcxx/test/libcxx-03/containers/associative/non_const_comparator.incomplete.verify.cpp b/libcxx/test/libcxx-03/containers/associative/non_const_comparator.incomplete.verify.cpp new file mode 100644 index 0000000000000..bae78ba4b78c6 --- /dev/null +++ b/libcxx/test/libcxx-03/containers/associative/non_const_comparator.incomplete.verify.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Test that libc++ does not generate a warning diagnostic about the comparator +// too early for containers of incomplete types. +// +// See PR41360. + +#include +#include +#include + +template