[libcxx-commits] [PATCH] D154017: Cleanup __uninitialized_temporary_buffer internals.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 29 14:36:35 PDT 2023


ldionne added inline comments.


================
Comment at: libcxx/include/__memory/uninitialized_buffer.h:46
+ *
+ * Attempt to allocate an uninitialized buffer of `__count` elements of type `_Tp`..
+ * In case of allocation failure, the returned object will contain a nullptr and count 0.
----------------
Nit: `..` => `.`


================
Comment at: libcxx/include/__memory/uninitialized_buffer.h:51-53
+ * 1. No initialization or destruction of elements:
+ *    It is the callers responsibility to manage both construction and destruction of the elements created
+ *    in the buffer.
----------------
The ability to have a non-trivial destructor was the reason why we created this class and refactored the existing uses of `get_temporary_buffer()` in the first place. We can't remove this functionality, this is needed for implementing the GCD backend in the PSTL.


================
Comment at: libcxx/include/__memory/uninitialized_buffer.h:61
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI __uninitialized_buffer_t<_Tp>
+__maybe_allocate_uninitialized_buffer(size_t __count) {
+  _Tp* __ptr = static_cast<_Tp*>(std::__libcpp_allocate(sizeof(_Tp) * __count, _LIBCPP_ALIGNOF(_Tp), nothrow));
----------------
`__try_allocate_uninitialized_buffer`?


================
Comment at: libcxx/include/new:297
 
+inline _LIBCPP_INLINE_VISIBILITY
+void *__libcpp_allocate(size_t __size, size_t __align, nothrow_t) {
----------------
EricWF wrote:
> Mordante wrote:
> > s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/
> Do we have a doc describing what the difference is and providing top? That way I can stop making the mistake in the future?
>From `__config`:

```
// Just so we can migrate to the new macros gradually.
#  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154017/new/

https://reviews.llvm.org/D154017



More information about the libcxx-commits mailing list