[libcxx-commits] [libcxx] 46016e6 - [libc++] Make basic_string::__erase_external_with_move noexcept (#171591)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 12 06:47:28 PST 2026
Author: Nikolas Klauser
Date: 2026-01-12T15:47:23+01:00
New Revision: 46016e63b710f3a9b9742bb4c6540f1dde1bd451
URL: https://github.com/llvm/llvm-project/commit/46016e63b710f3a9b9742bb4c6540f1dde1bd451
DIFF: https://github.com/llvm/llvm-project/commit/46016e63b710f3a9b9742bb4c6540f1dde1bd451.diff
LOG: [libc++] Make basic_string::__erase_external_with_move noexcept (#171591)
`__erase_external_with_move` is in the dylib, so the compiler doesn't
see the definition. Marking it `noexcept` sometimes allows clang to
remove exceptions related code, improving code size slightly.
Added:
Modified:
libcxx/include/string
Removed:
################################################################################
diff --git a/libcxx/include/string b/libcxx/include/string
index 8d49822f6fb39..34af7efb56659 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2463,7 +2463,8 @@ private:
// __erase_external_with_move is invoked for erase() invocations where
// `n ~= npos`, likely requiring memory moves on the string data.
- _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void __erase_external_with_move(size_type __pos, size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void
+ __erase_external_with_move(size_type __pos, size_type __n) _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str) {
__copy_assign_alloc(
@@ -3329,7 +3330,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
// Does not check __pos against size()
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void
-basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type __pos, size_type __n) {
+basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type __pos, size_type __n) _NOEXCEPT {
if (__n == 0)
return;
More information about the libcxx-commits
mailing list