[all-commits] [llvm/llvm-project] 83dfac: [libc] Implement cpp::unique_ptr utility (#206701)

Jeff Bailey via All-commits all-commits at lists.llvm.org
Tue Jul 28 13:04:04 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 83dfacdbda1a8b87c1f170ec6ce4e240e1fa79db
      https://github.com/llvm/llvm-project/commit/83dfacdbda1a8b87c1f170ec6ce4e240e1fa79db
  Author: Jeff Bailey <jbailey at raspberryginger.com>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    M libc/src/__support/CPP/CMakeLists.txt
    M libc/src/__support/CPP/type_traits.h
    A libc/src/__support/CPP/unique_ptr.h
    M libc/src/__support/macros/attributes.h
    M libc/test/src/__support/CPP/CMakeLists.txt
    A libc/test/src/__support/CPP/unique_ptr_test.cpp

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list