Skip to content

Commit e2d07fc

Browse files
authored
[libc++] Mark libc++ deallocation helpers as noexcept (llvm#110884)
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 llvm#66100
1 parent 8c77f4c commit e2d07fc

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
@@ -281,7 +281,7 @@ _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
281281
}
282282

283283
template <class... _Args>
284-
_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) {
284+
_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
285285
#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
286286
__builtin_operator_delete(__args...);
287287
#else
@@ -302,7 +302,7 @@ inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __ali
302302
}
303303

304304
template <class... _Args>
305-
_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) {
305+
_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) _NOEXCEPT {
306306
#if !_LIBCPP_HAS_SIZED_DEALLOCATION
307307
(void)__size;
308308
return std::__libcpp_operator_delete(__ptr, __args...);
@@ -311,7 +311,7 @@ _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __siz
311311
#endif
312312
}
313313

314-
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
314+
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) _NOEXCEPT {
315315
#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
316316
(void)__align;
317317
return __do_deallocate_handle_size(__ptr, __size);
@@ -325,7 +325,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size
325325
#endif
326326
}
327327

328-
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
328+
inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) _NOEXCEPT {
329329
#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
330330
(void)__align;
331331
return __libcpp_operator_delete(__ptr);

0 commit comments

Comments
 (0)