Add some const_casts in places where we were implicitly casting away constness. No functional change, but now they're explicit

llvm-svn: 305410
This commit is contained in:
Marshall Clow 2017-06-14 20:00:36 +00:00
parent 0dc4778067
commit 8b086e3878
5 changed files with 15 additions and 13 deletions

View File

@ -704,7 +704,7 @@ function<_Rp()>::target()
{ {
if (__f_ == 0) if (__f_ == 0)
return (_Tp*)0; return (_Tp*)0;
return (_Tp*)__f_->target(typeid(_Tp)); return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
} }
template<class _Rp> template<class _Rp>
@ -980,7 +980,7 @@ function<_Rp(_A0)>::target()
{ {
if (__f_ == 0) if (__f_ == 0)
return (_Tp*)0; return (_Tp*)0;
return (_Tp*)__f_->target(typeid(_Tp)); return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
} }
template<class _Rp, class _A0> template<class _Rp, class _A0>
@ -1256,7 +1256,7 @@ function<_Rp(_A0, _A1)>::target()
{ {
if (__f_ == 0) if (__f_ == 0)
return (_Tp*)0; return (_Tp*)0;
return (_Tp*)__f_->target(typeid(_Tp)); return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
} }
template<class _Rp, class _A0, class _A1> template<class _Rp, class _A0, class _A1>
@ -1532,7 +1532,7 @@ function<_Rp(_A0, _A1, _A2)>::target()
{ {
if (__f_ == 0) if (__f_ == 0)
return (_Tp*)0; return (_Tp*)0;
return (_Tp*)__f_->target(typeid(_Tp)); return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
} }
template<class _Rp, class _A0, class _A1, class _A2> template<class _Rp, class _A0, class _A1, class _A2>

View File

@ -617,7 +617,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
static_cast<size_t>(__extbufend_ - __extbufnext_)); static_cast<size_t>(__extbufend_ - __extbufnext_));
codecvt_base::result __r; codecvt_base::result __r;
__st_last_ = __st_; __st_last_ = __st_;
size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_); size_t __nr = fread((void*) const_cast<char *>(__extbufnext_), 1, __nmemb, __file_);
if (__nr != 0) if (__nr != 0)
{ {
if (!__cv_) if (!__cv_)
@ -630,7 +630,8 @@ basic_filebuf<_CharT, _Traits>::underflow()
this->eback() + __ibs_, __inext); this->eback() + __ibs_, __inext);
if (__r == codecvt_base::noconv) if (__r == codecvt_base::noconv)
{ {
this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_); this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
(char_type*)const_cast<char *>(__extbufend_));
__c = traits_type::to_int_type(*this->gptr()); __c = traits_type::to_int_type(*this->gptr());
} }
else if (__inext != this->eback() + __unget_sz) else if (__inext != this->eback() + __unget_sz)
@ -722,7 +723,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
return traits_type::eof(); return traits_type::eof();
if (__r == codecvt_base::partial) if (__r == codecvt_base::partial)
{ {
this->setp((char_type*)__e, this->pptr()); this->setp(const_cast<char_type*>(__e), this->pptr());
this->pbump(this->epptr() - this->pbase()); this->pbump(this->epptr() - this->pbase());
} }
} }

View File

@ -1941,8 +1941,8 @@ _Tp*
function<_Rp(_ArgTypes...)>::target() _NOEXCEPT function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
{ {
if (__f_ == 0) if (__f_ == 0)
return (_Tp*)0; return nullptr;
return (_Tp*)__f_->target(typeid(_Tp)); return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
} }
template<class _Rp, class ..._ArgTypes> template<class _Rp, class ..._ArgTypes>
@ -1951,7 +1951,7 @@ const _Tp*
function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
{ {
if (__f_ == 0) if (__f_ == 0)
return (const _Tp*)0; return nullptr;
return (const _Tp*)__f_->target(typeid(_Tp)); return (const _Tp*)__f_->target(typeid(_Tp));
} }

View File

@ -3960,7 +3960,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
this->egptr(), __inext); this->egptr(), __inext);
if (__r == codecvt_base::noconv) if (__r == codecvt_base::noconv)
{ {
this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_); this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
(char_type*) const_cast<char *>(__extbufend_));
__c = *this->gptr(); __c = *this->gptr();
} }
else if (__inext != this->eback() + __unget_sz) else if (__inext != this->eback() + __unget_sz)
@ -4048,7 +4049,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
return traits_type::eof(); return traits_type::eof();
if (__r == codecvt_base::partial) if (__r == codecvt_base::partial)
{ {
this->setp((char_type*)__e, this->pptr()); this->setp(const_cast<char_type *>(__e), this->pptr());
this->pbump(this->epptr() - this->pbase()); this->pbump(this->epptr() - this->pbase());
} }
} }

View File

@ -104,7 +104,7 @@ public:
T* allocate(std::size_t, const void* hint) T* allocate(std::size_t, const void* hint)
{ {
allocate_called = true; allocate_called = true;
return (T*)hint; return (T*) const_cast<void *>(hint);
} }
}; };