[libcxx-commits] [PATCH] D66177: Update shared_ptr's constructor
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 22 12:21:30 PDT 2019
ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.
================
Comment at: libcxx/include/memory:3979
+ : __ptr_(__p),
+ __cntrl_(__allocate_shared(__p))
{
----------------
Before, we would create the control block with `new`, and with this patch we're using the allocator. Is this correct? Why?
Also, we're now unconditionally using a try-catch block -- I'd be curious to see what the impact on code generation is.
================
Comment at: libcxx/include/memory:3991
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
- typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
- __enable_weak_this(__p, __p);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __d(__p);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
+ __enable_weak_this(__p, __p);
}
----------------
Note to reviewers: It's okay to move this outside of the try-catch block, since `__enable_weak_this` is `noexcept` anyway.
Repository:
rCXX libc++
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66177/new/
https://reviews.llvm.org/D66177
More information about the libcxx-commits
mailing list