diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2017-06-14 16:54:43 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2017-06-14 16:54:43 +0000 |
| commit | 4a911c867fec9fc71c561b7d0cea088b749f6ec0 (patch) | |
| tree | 815fff1b2f101c1dd498e5390be3b5a67a305752 | |
| parent | 1953434f2922f0955a37ef27d38cf9dbe4e8ab1c (diff) | |
| download | bcm5719-llvm-4a911c867fec9fc71c561b7d0cea088b749f6ec0.tar.gz bcm5719-llvm-4a911c867fec9fc71c561b7d0cea088b749f6ec0.zip | |
In several places in std::allocator<const T> (and one in shared_ptr, we were casting a 'const T*' to a 'void *' - implicitly casting away the const. Add const_cast to make that explicit. No functional change.
llvm-svn: 305397
| -rw-r--r-- | libcxx/include/memory | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libcxx/include/memory b/libcxx/include/memory index 711551d5732..4765bff299d 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -1884,7 +1884,7 @@ public: return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp))); } _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT - {_VSTD::__libcpp_deallocate((void*)__p);} + {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p));} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {return size_type(~0) / sizeof(_Tp);} #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) @@ -1900,7 +1900,7 @@ public: void construct(pointer __p) { - ::new((void*)__p) _Tp(); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(); } # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) @@ -1909,14 +1909,14 @@ public: void construct(pointer __p, _A0& __a0) { - ::new((void*)__p) _Tp(__a0); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0); } template <class _A0> _LIBCPP_INLINE_VISIBILITY void construct(pointer __p, const _A0& __a0) { - ::new((void*)__p) _Tp(__a0); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0); } # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) template <class _A0, class _A1> @@ -1924,28 +1924,28 @@ public: void construct(pointer __p, _A0& __a0, _A1& __a1) { - ::new((void*)__p) _Tp(__a0, __a1); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1); } template <class _A0, class _A1> _LIBCPP_INLINE_VISIBILITY void construct(pointer __p, const _A0& __a0, _A1& __a1) { - ::new((void*)__p) _Tp(__a0, __a1); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1); } template <class _A0, class _A1> _LIBCPP_INLINE_VISIBILITY void construct(pointer __p, _A0& __a0, const _A1& __a1) { - ::new((void*)__p) _Tp(__a0, __a1); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1); } template <class _A0, class _A1> _LIBCPP_INLINE_VISIBILITY void construct(pointer __p, const _A0& __a0, const _A1& __a1) { - ::new((void*)__p) _Tp(__a0, __a1); + ::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1); } #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} @@ -3890,7 +3890,9 @@ public: template <class _Dp> _LIBCPP_INLINE_VISIBILITY _Dp* __get_deleter() const _NOEXCEPT - {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} + {return static_cast<_Dp*>(__cntrl_ + ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp))) + : nullptr);} #endif // _LIBCPP_NO_RTTI #ifndef _LIBCPP_HAS_NO_VARIADICS |

