[libcxx-commits] [libcxx] 475f831 - [libc++][NFCI] Remove unnecessary exception-throwing base classes

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 19 11:00:01 PDT 2021


Author: Louis Dionne
Date: 2021-08-19T13:59:57-04:00
New Revision: 475f831b178c917206cc89925c3ee63b2aec088d

URL: https://github.com/llvm/llvm-project/commit/475f831b178c917206cc89925c3ee63b2aec088d
DIFF: https://github.com/llvm/llvm-project/commit/475f831b178c917206cc89925c3ee63b2aec088d.diff

LOG: [libc++][NFCI] Remove unnecessary exception-throwing base classes

__split_buffer_common was entirely unused, and __deque_base_common
was unused except for two calls to __throw_out_of_range(), which have
been inlined.

The usual intent of the __xxx_base_common base classes is to localize
where the exception-throwing code is instantiated, however that wasn't
the case here because we never explicitly instantiated those base classes
in the shared library, unlike what we do for basic_string and vector.

Differential Revision: https://reviews.llvm.org/D108384

Added: 
    

Modified: 
    libcxx/include/__split_buffer
    libcxx/include/deque

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index 901c0374aa1c4..0c02e035814bd 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -17,17 +17,8 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <bool>
-class __split_buffer_common
-{
-protected:
-    _LIBCPP_NORETURN void __throw_length_error() const;
-    _LIBCPP_NORETURN void __throw_out_of_range() const;
-};
-
 template <class _Tp, class _Allocator = allocator<_Tp> >
 struct __split_buffer
-    : private __split_buffer_common<true>
 {
 private:
     __split_buffer(const __split_buffer&);

diff  --git a/libcxx/include/deque b/libcxx/include/deque
index 37ba58684ac0d..f4caa9ef0af24 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -908,31 +908,8 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
     return __r;
 }
 
-template <bool>
-class __deque_base_common
-{
-protected:
-    _LIBCPP_NORETURN void __throw_length_error() const;
-    _LIBCPP_NORETURN void __throw_out_of_range() const;
-};
-
-template <bool __b>
-void
-__deque_base_common<__b>::__throw_length_error() const
-{
-    _VSTD::__throw_length_error("deque");
-}
-
-template <bool __b>
-void
-__deque_base_common<__b>::__throw_out_of_range() const
-{
-    _VSTD::__throw_out_of_range("deque");
-}
-
 template <class _Tp, class _Allocator>
 class __deque_base
-    : protected __deque_base_common<true>
 {
     __deque_base(const __deque_base& __c);
     __deque_base& operator=(const __deque_base& __c);
@@ -1873,7 +1850,7 @@ typename deque<_Tp, _Allocator>::reference
 deque<_Tp, _Allocator>::at(size_type __i)
 {
     if (__i >= __base::size())
-        __base::__throw_out_of_range();
+        _VSTD::__throw_out_of_range("deque");
     size_type __p = __base::__start_ + __i;
     return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
 }
@@ -1884,7 +1861,7 @@ typename deque<_Tp, _Allocator>::const_reference
 deque<_Tp, _Allocator>::at(size_type __i) const
 {
     if (__i >= __base::size())
-        __base::__throw_out_of_range();
+        _VSTD::__throw_out_of_range("deque");
     size_type __p = __base::__start_ + __i;
     return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
 }


        


More information about the libcxx-commits mailing list