[libcxx-commits] [libcxx] [libc++] Make basic_string::__erase_external_with_move noexcept (PR #171591)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 9 07:51:20 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
`__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.
---
Full diff: https://github.com/llvm/llvm-project/pull/171591.diff
1 Files Affected:
- (modified) libcxx/include/string (+3-2)
``````````diff
diff --git a/libcxx/include/string b/libcxx/include/string
index 2b3ba6d2d9b62..b1f1b30237d86 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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/171591
More information about the libcxx-commits
mailing list