mirror-llvm-project/libc/test
Jeff Bailey 83dfacdbda
[libc] Implement cpp::unique_ptr utility (#206701)
[libc] Implement cpp::unique_ptr utility

Implemented cpp::unique_ptr and cpp::default_delete in
libc/src/__support/CPP/unique_ptr.h for internal use within LLVM-libc.

* Added cpp::default_delete and its array specialization.
* Implemented cpp::unique_ptr with support for custom deleters and
  array specialization.
* Applied LIBC_TRIVIAL_ABI to unique_ptr and LIBC_NO_UNIQUE_ADDRESS to
the
  deleter to enable empty member optimization and register-passing ABI.
* Defined portable LIBC_NO_UNIQUE_ADDRESS and LIBC_TRIVIAL_ABI macros in
  attributes.h.
* Included is_assignable.h in type_traits.h to support conversion
  assignment constraints.
* Modernized template constraints using enable_if_t and
is_convertible_v.
* Added comprehensive unit tests in
libc/test/src/__support/CPP/unique_ptr_test.cpp, including coverage for
  reset sequencing, custom deleters, and conversion constructors.

This is a simplified implementation with the following limitations:
* No support for custom pointer types (hardcoded to T*).
* No support for reference deleter types or array conversion.

Adding this to LLVM libc because some things (like regex) require
dynamic
memory allocation, and this will help with correct memory management.

Assisted-by: Automated tooling, human reviewed.
2026-07-28 21:03:40 +01:00
..
include [libc] Implement alloca.h header (#210150) 2026-07-16 21:43:12 +01:00
integration [libc][stdlib] Add putenv (#208339) 2026-07-28 15:35:04 +01:00
IntegrationTest [libc] Fix -Wshadow warning in IntegrationTest/test.cpp (#196858) 2026-05-11 16:06:20 -04:00
shared [libc] Migrate printf_core from stdio/ to __support/. (#208303) 2026-07-21 14:35:24 -07:00
src [libc] Implement cpp::unique_ptr utility (#206701) 2026-07-28 21:03:40 +01:00
UnitTest [libc] Add aligned_alloc and delete[] to hermetic tests (#210693) 2026-07-28 08:57:05 +02:00
utils [libc][NFC] Reduce the test size for math functions by default. (#199308) 2026-05-22 21:45:01 -04:00
CMakeLists.txt [libc][NFC] Add few options to allow users to skip building and running some tests. (#199474) 2026-05-29 12:52:11 -04:00
lit.cfg.py [libc] Implement lit-based test execution for Libc (#178746) 2026-02-13 18:39:54 +00:00
lit.site.cfg.py.in [libc] Honour LIBC_GPU_TEST_JOBS in lit test runs (#193797) 2026-04-24 08:20:03 +01:00