Skip to content

Commit 2f53dd9

Browse files
committed
[libc++] Mark libc++ deallocation helpers as noexcept
They already can't throw exceptions and they are called from noexcept functions, but they were not marked as noexcept. Depending on compiler inlining, this might not make a difference or this might improve the codegen a bit by removing the implicit try-catch block that Clang generates around non-noexcept functions called from noexcept functions. The original issue also mentioned that one occurrence of std::allocator::deallocate was missing noexcept, however it has since then been removed. Fixes #66100
1 parent 5867362 commit 2f53dd9

File tree

1 file changed

+4
-4
lines changed
  • libcxx/include

1 file changed

+4
-4
lines changed

libcxx/include/new

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
275275
}
276276

277277
template <class... _Args>
278-
_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) {
278+
_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
279279
#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
280280
__builtin_operator_delete(__args...);
281281
#else
@@ -296,7 +296,7 @@ inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __ali
296296
}
297297

298298
template <class... _Args>
299-
_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) {
299+
_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) _NOEXCEPT {
300300
#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
301301
(void)__size;
302302
return std::__libcpp_operator_delete(__ptr, __args...);
@@ -305,7 +305,7 @@ _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __siz
305305
#endif
306306
}
307307

308-
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
308+
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) _NOEXCEPT {
309309
#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
310310
(void)__align;
311311
return __do_deallocate_handle_size(__ptr, __size);
@@ -319,7 +319,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size
319319
#endif
320320
}
321321

322-
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
322+
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) _NOEXCEPT {
323323
#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
324324
(void)__align;
325325
return __libcpp_operator_delete(__ptr);

0 commit comments

Comments
 (0)