[libcxx] r305410 - Add some const_casts in places where we were implicitly casting away constness. No functional change, but now they're explicit
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 13:00:37 PDT 2017
Author: marshall
Date: Wed Jun 14 15:00:36 2017
New Revision: 305410
URL: http://llvm.org/viewvc/llvm-project?rev=305410&view=rev
Log:
Add some const_casts in places where we were implicitly casting away constness. No functional change, but now they're explicit
Modified:
libcxx/trunk/include/__functional_03
libcxx/trunk/include/fstream
libcxx/trunk/include/functional
libcxx/trunk/include/locale
libcxx/trunk/test/support/allocators.h
Modified: libcxx/trunk/include/__functional_03
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_03?rev=305410&r1=305409&r2=305410&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_03 (original)
+++ libcxx/trunk/include/__functional_03 Wed Jun 14 15:00:36 2017
@@ -704,7 +704,7 @@ function<_Rp()>::target()
{
if (__f_ == 0)
return (_Tp*)0;
- return (_Tp*)__f_->target(typeid(_Tp));
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
}
template<class _Rp>
@@ -980,7 +980,7 @@ function<_Rp(_A0)>::target()
{
if (__f_ == 0)
return (_Tp*)0;
- return (_Tp*)__f_->target(typeid(_Tp));
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
}
template<class _Rp, class _A0>
@@ -1256,7 +1256,7 @@ function<_Rp(_A0, _A1)>::target()
{
if (__f_ == 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>
@@ -1532,7 +1532,7 @@ function<_Rp(_A0, _A1, _A2)>::target()
{
if (__f_ == 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>
Modified: libcxx/trunk/include/fstream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=305410&r1=305409&r2=305410&view=diff
==============================================================================
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Wed Jun 14 15:00:36 2017
@@ -617,7 +617,7 @@ basic_filebuf<_CharT, _Traits>::underflo
static_cast<size_t>(__extbufend_ - __extbufnext_));
codecvt_base::result __r;
__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 (!__cv_)
@@ -630,7 +630,8 @@ basic_filebuf<_CharT, _Traits>::underflo
this->eback() + __ibs_, __inext);
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());
}
else if (__inext != this->eback() + __unget_sz)
@@ -722,7 +723,7 @@ basic_filebuf<_CharT, _Traits>::overflow
return traits_type::eof();
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());
}
}
Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=305410&r1=305409&r2=305410&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Wed Jun 14 15:00:36 2017
@@ -1941,8 +1941,8 @@ _Tp*
function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
{
if (__f_ == 0)
- return (_Tp*)0;
- return (_Tp*)__f_->target(typeid(_Tp));
+ return nullptr;
+ return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
}
template<class _Rp, class ..._ArgTypes>
@@ -1951,7 +1951,7 @@ const _Tp*
function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
{
if (__f_ == 0)
- return (const _Tp*)0;
+ return nullptr;
return (const _Tp*)__f_->target(typeid(_Tp));
}
Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=305410&r1=305409&r2=305410&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Wed Jun 14 15:00:36 2017
@@ -3960,7 +3960,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::u
this->egptr(), __inext);
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();
}
else if (__inext != this->eback() + __unget_sz)
@@ -4048,7 +4049,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::o
return traits_type::eof();
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());
}
}
Modified: libcxx/trunk/test/support/allocators.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/allocators.h?rev=305410&r1=305409&r2=305410&view=diff
==============================================================================
--- libcxx/trunk/test/support/allocators.h (original)
+++ libcxx/trunk/test/support/allocators.h Wed Jun 14 15:00:36 2017
@@ -104,7 +104,7 @@ public:
T* allocate(std::size_t, const void* hint)
{
allocate_called = true;
- return (T*)hint;
+ return (T*) const_cast<void *>(hint);
}
};
More information about the cfe-commits
mailing list