llvm-project/libcxx/test/support
Louis Dionne b0fd9497af [libc++] Add a lightweight overridable assertion handler
This patch adds a lightweight assertion handler mechanism that can be
overriden at link-time in a fashion similar to `operator new`.

This is a third take on https://llvm.org/D121123 (which allowed customizing
the assertion handler at compile-time), and https://llvm.org/D119969
(which allowed customizing the assertion handler at runtime only).

This approach is, I think, the best of all three explored approaches.
Indeed, replacing the assertion handler in user code is ergonomic,
yet we retain the ability to provide a custom assertion handler when
deploying to older platforms that don't have a default handler in
the dylib.

As-is, this patch provides a pretty good amount of backwards compatibility
with the previous debug mode:

- Code that used to set _LIBCPP_DEBUG=0 in order to get basic assertions
  in their code will still get basic assertions out of the box, but
  those assertions will be using the new assertion handler support.
- Code that was previously compiled with references to __libcpp_debug_function
  and friends will work out-of-the-box, no changes required. This is
  because we provide the same symbols in the dylib as we used to.
- Code that used to set a custom __libcpp_debug_function will stop
  compiling, because we don't provide that declaration anymore. Users
  will have to migrate to the new way of setting a custom assertion
  handler, which is extremely easy. I suspect that pool of users is
  very limited, so breaking them at compile-time is probably acceptable.

The main downside of this approach is that code being compiled with
assertions enabled but deploying to an older platform where the assertion
handler didn't exist yet will fail to compile. However users can easily
fix the problem by providing a custom assertion handler and defining
the _LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED macro to
let the library know about the custom handler. In a way, this is
actually a feature because it avoids a load-time error that one would
otherwise get when trying to run the code on the older target.

Differential Revision: https://reviews.llvm.org/D121478
2022-03-23 15:35:46 -04:00
..
test.support [libc++] Add a lightweight overridable assertion handler 2022-03-23 15:35:46 -04:00
test.workarounds [libcxx][test] compiler options are non-portable 2022-01-18 11:34:57 -08:00
type_classification [libc++] Define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER whenever we enable warnings in the test suite 2022-03-15 17:17:54 -04:00
Counter.h
DefaultOnly.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
MoveOnly.h [libc++][test] Clean up libcxx/test/support/MoveOnly.h 2022-01-29 18:20:46 -05:00
allocators.h [libcxx][test][NFC] Various tests for std::vector 2021-12-02 02:11:45 +03:00
almost_satisfies_types.h [libc++][ranges] Implement ranges::find{, _if, _if_not} 2022-03-12 01:46:02 +01:00
any_helpers.h [libc++][NFC] Remove uses of 'using namespace std;' in the test suite 2021-09-03 13:15:10 -04:00
archetypes.h [libcxx][test] compiler options are non-portable 2022-01-18 11:34:57 -08:00
archetypes.ipp
asan_testing.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
atomic_helpers.h [libc++][nfc] Add TEST_HAS_NO_UNICODE_CHARS. 2022-02-03 08:02:25 +01:00
callable_types.h [libc++] Add bind_front function (P0356R5). 2021-03-02 16:18:06 -08:00
charconv_test_helpers.h [libc++] Add warning pragma macros in the test suite 2022-03-17 00:11:20 +01:00
check_assertion.h [libc++] Add a lightweight overridable assertion handler 2022-03-23 15:35:46 -04:00
cmpxchg_loop.h
compare_types.h [libc++] Remove random [[nodiscard]] in the test suite 2021-07-12 12:45:21 -04:00
constexpr_char_traits.h [libc++] [test] Remove filenames from copyright headers. NFCI. 2021-10-01 12:14:00 -04:00
container_debug_tests.h [libc++] Overhaul all tests for assertions and debug mode 2022-03-15 10:56:34 -04:00
container_test_types.h [libc++] s/insertible/insertable/g. NFCI. 2020-12-14 09:54:58 -05:00
controlled_allocators.h [libc++] Remove uses of printf in some test support headers 2021-11-22 12:01:18 -05:00
count_new.h [libc++] Add warning pragma macros in the test suite 2022-03-17 00:11:20 +01:00
counting_predicates.h
deduction_guides_sfinae_checks.h [libc++] P0433R2: test that deduction guides are properly SFINAEd away. 2021-11-09 09:32:24 -08:00
deleter_types.h [libc++] Value-initialize unique_ptr's deleter_type 2021-11-24 17:31:34 -05:00
emplace_constructible.h
experimental_any_helpers.h [libc++] Fix failures when running the test suite without RTTI 2020-09-21 20:17:24 -04:00
external_threads.cpp
filesystem_include.h
filesystem_test_helper.h [libcxx] [test] Make filesystem tests not rely on libc++ internals 2022-03-02 10:39:14 +02:00
format_string.h
fp_compare.h
hexfloat.h
indirectly_readable.h [libc++] Add all indirect callable concepts and projected 2021-05-28 10:10:44 -04:00
is_transparent.h [libc++] [P0919] Some belated review on D87171. 2021-09-20 14:46:38 -04:00
iterator_traits_cpp17_iterators.h [libcxx] makes `iterator_traits` C++20-aware 2021-04-20 11:30:08 -04:00
locale_helpers.h [libcxx] [test] Fix get_string_en_US, get_long_double_en_US for Windows 2022-03-04 10:18:07 +02:00
make_implicit.h [libc++] [P0935] [C++20] Eradicating unnecessarily explicit default constructors from the standard library. 2021-01-19 08:22:06 +01:00
make_string.h [libc++] [test] C++03-friendly MAKE_STRING macro. 2021-12-01 15:02:53 -05:00
make_test_thread.h [libc++] Introduce an indirection to create threads in the test suite 2020-11-27 11:54:19 -05:00
min_allocator.h [libc++] [test] Update "test_compare.h" users to avoid removed-in-C++20 members. NFCI. 2021-05-29 16:54:24 -04:00
msvc_stdlib_force_include.h [libcxx][test] Update msvc_stdlib_force_include.h for C++23 2022-02-20 11:35:33 -08:00
nasty_containers.h [libc++] [test] Constexpr-ify a couple of insert-iterator tests. 2021-05-28 15:15:50 -04:00
operator_hijacker.h [libc++] Use addressof in assignment operator. 2021-10-07 18:10:47 +02:00
parse_integer.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
platform_support.h [libcxx] [test] Use proper UTF-8 locales on Windows 2022-02-18 00:02:34 +02:00
pointer_comparison_test_helper.h [libcxx][nfc] Add license to `pointer_comparison_test_helper.h` 2021-04-23 12:37:47 -07:00
poisoned_hash_helper.h [libc++] LWG2148, LWG2543: Enable std::hash<Enum> in C++03 and C++11. 2022-02-16 11:01:49 -05:00
private_constructor.h [libc++] Remove unnecessary usage of <iostream> in the test suite 2020-10-02 13:00:34 -04:00
propagate_const_helpers.h
propagate_value_category.hpp [libc++] Fix tuple assignment from types derived from a tuple-like 2021-02-22 14:52:18 -05:00
rapid-cxx-test.h
read_write.h [libc++] Re-apply `std::indirectly_readable` and `std::indirectly_writable` 2021-04-22 11:24:04 -04:00
set_windows_crt_report_mode.h
template_cost_testing.h
test_allocator.h [libc++] Make test_allocator constexpr-friendly for constexpr string/vector 2021-11-07 16:15:28 +01:00
test_basic_format_arg.h [libc++][format] Add __format_arg_store. 2021-09-01 19:45:02 +02:00
test_comparisons.h [libcxx][test][NFC] More tests for containers comparisons 2021-11-03 16:15:10 +03:00
test_constexpr_container.h [libcxx][test] Add missing includes and suppress warnings 2022-01-13 17:34:04 -08:00
test_convertible.h
test_format_context.h [libc++][format] Add __format_arg_store. 2021-09-01 19:45:02 +02:00
test_iterators.h [libc++] Replace _LIBCPP_HAS_NO_CONCEPTS with _LIBCPP_STD_VER > 17. NFCI. 2022-03-13 12:32:06 -04:00
test_macros.h [libc++] Re-enable workaround for pre-ranges CTAD in std::span 2022-03-21 21:56:42 -04:00
test_memory_resource.h
test_range.h [libc++] Replace _LIBCPP_HAS_NO_CONCEPTS with _LIBCPP_STD_VER > 17. NFCI. 2022-03-13 12:32:06 -04:00
test_transparent_unordered.h [libc++] [P0919] Some belated review on D87171. 2021-09-20 14:46:38 -04:00
test_workarounds.h [libcxx][test] compiler options are non-portable 2022-01-18 11:34:57 -08:00
truncate_fp.h
type_id.h [libc++] Remove uses of printf in some test support headers 2021-11-22 12:01:18 -05:00
unique_ptr_test_helper.h [libc++] Add warning pragma macros in the test suite 2022-03-17 00:11:20 +01:00
user_defined_integral.h
uses_alloc_types.h [libc++] Remove uses of printf in some test support headers 2021-11-22 12:01:18 -05:00
variant_test_helpers.h [libc++] Implement P0655R1 visit<R>: Explicit Return Type for visit 2021-01-25 11:14:45 -05:00