[libcxx] r198505 - Switch to using C++ style casts.

Joerg Sonnenberger joerg at bec.de
Sat Jan 4 09:43:00 PST 2014


Author: joerg
Date: Sat Jan  4 11:43:00 2014
New Revision: 198505

URL: http://llvm.org/viewvc/llvm-project?rev=198505&view=rev
Log:
Switch to using C++ style casts.

Modified:
    libcxx/trunk/src/ios.cpp
    libcxx/trunk/src/locale.cpp
    libcxx/trunk/src/memory.cpp
    libcxx/trunk/src/new.cpp
    libcxx/trunk/src/stdexcept.cpp
    libcxx/trunk/src/strstream.cpp
    libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/ios.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/ios.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/ios.cpp (original)
+++ libcxx/trunk/src/ios.cpp Sat Jan  4 11:43:00 2014
@@ -134,7 +134,7 @@ locale
 ios_base::imbue(const locale& newloc)
 {
     static_assert(sizeof(locale) == sizeof(__loc_), "");
-    locale& loc_storage = *(locale*)&__loc_;
+    locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
     locale oldloc = loc_storage;
     loc_storage = newloc;
     __call_callbacks(imbue_event);
@@ -144,7 +144,7 @@ ios_base::imbue(const locale& newloc)
 locale
 ios_base::getloc() const
 {
-    const locale& loc_storage = *(locale*)&__loc_;
+    const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
     return loc_storage;
 }
 
@@ -173,7 +173,8 @@ ios_base::iword(int index)
             newcap = _VSTD::max(2 * __iarray_cap_, req_size);
         else
             newcap = mx;
-        long* iarray = (long*)realloc(__iarray_, newcap * sizeof(long));
+        size_t newsize = newcap * sizeof(long);
+        long* iarray = static_cast<long*>(realloc(__iarray_, newsize));
         if (iarray == 0)
         {
             setstate(badbit);
@@ -201,7 +202,8 @@ ios_base::pword(int index)
             newcap = _VSTD::max(2 * __parray_cap_, req_size);
         else
             newcap = mx;
-        void** parray = (void**)realloc(__parray_, newcap * sizeof(void*));
+        size_t newsize = newcap * sizeof(void*);
+        void** parray = static_cast<void**>(realloc(__parray_, newsize));
         if (parray == 0)
         {
             setstate(badbit);
@@ -231,11 +233,13 @@ ios_base::register_callback(event_callba
             newcap = _VSTD::max(2 * __event_cap_, req_size);
         else
             newcap = mx;
-        event_callback* fns = (event_callback*)realloc(__fn_, newcap * sizeof(event_callback));
+        size_t newesize = newcap * sizeof(event_callback);
+        event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newesize));
         if (fns == 0)
             setstate(badbit);
         __fn_ = fns;
-        int* indxs = (int*)realloc(__index_, newcap * sizeof(int));
+        size_t newisize = newcap * sizeof(int);
+        int* indxs = static_cast<int *>(realloc(__index_, newisize));
         if (indxs == 0)
             setstate(badbit);
         __index_ = indxs;
@@ -248,7 +252,7 @@ ios_base::register_callback(event_callba
 ios_base::~ios_base()
 {
     __call_callbacks(erase_event);
-    locale& loc_storage = *(locale*)&__loc_;
+    locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
     loc_storage.~locale();
     free(__fn_);
     free(__index_);
@@ -306,12 +310,15 @@ ios_base::copyfmt(const ios_base& rhs)
     unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
     if (__event_cap_ < rhs.__event_size_)
     {
-        new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_));
+        size_t newesize = sizeof(event_callback) * rhs.__event_size_;
+        new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
 #ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_callbacks)
             throw bad_alloc();
 #endif  // _LIBCPP_NO_EXCEPTIONS
-        new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_));
+
+        size_t newisize = sizeof(int) * rhs.__event_size_;
+        new_ints.reset(static_cast<int *>(malloc(newisize)));
 #ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_ints)
             throw bad_alloc();
@@ -319,7 +326,8 @@ ios_base::copyfmt(const ios_base& rhs)
     }
     if (__iarray_cap_ < rhs.__iarray_size_)
     {
-        new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_));
+        size_t newsize = sizeof(long) * rhs.__iarray_size_;
+        new_longs.reset(static_cast<long*>(malloc(newsize)));
 #ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_longs)
             throw bad_alloc();
@@ -327,7 +335,8 @@ ios_base::copyfmt(const ios_base& rhs)
     }
     if (__parray_cap_ < rhs.__parray_size_)
     {
-        new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_));
+        size_t newsize = sizeof(void*) * rhs.__parray_size_;
+        new_pointers.reset(static_cast<void**>(malloc(newsize)));
 #ifndef _LIBCPP_NO_EXCEPTIONS
         if (!new_pointers)
             throw bad_alloc();
@@ -337,8 +346,8 @@ ios_base::copyfmt(const ios_base& rhs)
     __fmtflags_ = rhs.__fmtflags_;
     __precision_ = rhs.__precision_;
     __width_ = rhs.__width_;
-    locale& lhs_loc = *(locale*)&__loc_;
-    locale& rhs_loc = *(locale*)&rhs.__loc_;
+    locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+    const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
     lhs_loc = rhs_loc;
     if (__event_cap_ < rhs.__event_size_)
     {
@@ -381,7 +390,7 @@ ios_base::move(ios_base& rhs)
     __rdstate_ = rhs.__rdstate_;
     __exceptions_ = rhs.__exceptions_;
     __rdbuf_ = 0;
-    locale& rhs_loc = *(locale*)&rhs.__loc_;
+    locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
     ::new(&__loc_) locale(rhs_loc);
     __fn_ = rhs.__fn_;
     rhs.__fn_ = 0;
@@ -413,8 +422,8 @@ ios_base::swap(ios_base& rhs) _NOEXCEPT
     _VSTD::swap(__width_, rhs.__width_);
     _VSTD::swap(__rdstate_, rhs.__rdstate_);
     _VSTD::swap(__exceptions_, rhs.__exceptions_);
-    locale& lhs_loc = *(locale*)&__loc_;
-    locale& rhs_loc = *(locale*)&rhs.__loc_;
+    locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+    locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
     _VSTD::swap(lhs_loc, rhs_loc);
     _VSTD::swap(__fn_, rhs.__fn_);
     _VSTD::swap(__index_, rhs.__index_);

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Sat Jan  4 11:43:00 2014
@@ -68,7 +68,7 @@ make(A0 a0)
 {
     static typename aligned_storage<sizeof(T)>::type buf;
     ::new (&buf) T(a0);
-    return *(T*)&buf;
+    return *reinterpret_cast<T*>(&buf);
 }
 
 template <class T, class A0, class A1>
@@ -78,7 +78,7 @@ make(A0 a0, A1 a1)
 {
     static typename aligned_storage<sizeof(T)>::type buf;
     ::new (&buf) T(a0, a1);
-    return *(T*)&buf;
+    return *reinterpret_cast<T*>(&buf);
 }
 
 template <class T, class A0, class A1, class A2>
@@ -88,7 +88,7 @@ make(A0 a0, A1 a1, A2 a2)
 {
     static typename aligned_storage<sizeof(T)>::type buf;
     ::new (&buf) T(a0, a1, a2);
-    return *(T*)&buf;
+    return *reinterpret_cast<T*>(&buf);
 }
 
 template <typename T, size_t N>
@@ -177,7 +177,7 @@ locale::__imp::__imp(size_t refs)
     facets_.clear();
     install(&make<_VSTD::collate<char> >(1u));
     install(&make<_VSTD::collate<wchar_t> >(1u));
-    install(&make<_VSTD::ctype<char> >((ctype_base::mask*)0, false, 1u));
+    install(&make<_VSTD::ctype<char> >(nullptr, false, 1u));
     install(&make<_VSTD::ctype<wchar_t> >(1u));
     install(&make<codecvt<char, char, mbstate_t> >(1u));
     install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
@@ -461,7 +461,7 @@ locale::__imp::make_classic()
 {
     // only one thread can get in here and it only gets in once
     static aligned_storage<sizeof(locale)>::type buf;
-    locale* c = (locale*)&buf;
+    locale* c = reinterpret_cast<locale*>(&buf);
     c->__locale_ = &make<__imp>(1u);
     return *c;
 }
@@ -479,7 +479,7 @@ locale::__imp::make_global()
     // only one thread can get in here and it only gets in once
     static aligned_storage<sizeof(locale)>::type buf;
     ::new (&buf) locale(locale::classic());
-    return *(locale*)&buf;
+    return *reinterpret_cast<locale*>(&buf);
 }
 
 locale&
@@ -1615,9 +1615,9 @@ int
 codecvt<wchar_t, char, mbstate_t>::do_encoding() const  _NOEXCEPT
 {
 #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-    if (mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0)
+    if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
 #else
-    if (__mbtowc_l((wchar_t*) 0, (const char*) 0, MB_LEN_MAX, __l) == 0)
+    if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
 #endif
     {
         // stateless encoding
@@ -1743,8 +1743,8 @@ utf16_to_utf8(const uint16_t* frm, const
                 return codecvt_base::error;
             if (to_end-to_nxt < 4)
                 return codecvt_base::partial;
-            if ((((((unsigned long)wc1 & 0x03C0) >> 6) + 1) << 16) +
-                (((unsigned long)wc1 & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode)
+            if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
+                ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
                 return codecvt_base::error;
             ++frm_nxt;
             uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
@@ -1820,8 +1820,8 @@ utf16_to_utf8(const uint32_t* frm, const
                 return codecvt_base::error;
             if (to_end-to_nxt < 4)
                 return codecvt_base::partial;
-            if ((((((unsigned long)wc1 & 0x03C0) >> 6) + 1) << 16) +
-                (((unsigned long)wc1 & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode)
+            if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
+                ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
                 return codecvt_base::error;
             ++frm_nxt;
             uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
@@ -1944,9 +1944,9 @@ utf8_to_utf16(const uint8_t* frm, const
                 return codecvt_base::error;
             if (to_end-to_nxt < 2)
                 return codecvt_base::partial;
-            if (((((unsigned long)c1 & 7) << 18) +
-                (((unsigned long)c2 & 0x3F) << 12) +
-                (((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
+            if ((((c1 & 7UL) << 18) +
+                ((c2 & 0x3FUL) << 12) +
+                ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
                 return codecvt_base::error;
             *to_nxt = static_cast<uint16_t>(
                     0xD800
@@ -2065,9 +2065,9 @@ utf8_to_utf16(const uint8_t* frm, const
                 return codecvt_base::error;
             if (to_end-to_nxt < 2)
                 return codecvt_base::partial;
-            if (((((unsigned long)c1 & 7) << 18) +
-                (((unsigned long)c2 & 0x3F) << 12) +
-                (((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
+            if ((((c1 & 7UL) << 18) +
+                ((c2 & 0x3FUL) << 12) +
+                ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
                 return codecvt_base::error;
             *to_nxt = static_cast<uint32_t>(
                     0xD800
@@ -2174,9 +2174,9 @@ utf8_to_utf16_length(const uint8_t* frm,
             }
             if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
                 break;
-            if (((((unsigned long)c1 & 7) << 18) +
-                (((unsigned long)c2 & 0x3F) << 12) +
-                (((unsigned long)c3 & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
+            if ((((c1 & 7UL) << 18) +
+                ((c2 & 0x3FUL) << 12) +
+                ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
                 break;
             ++nchar16_t;
             frm_nxt += 4;

Modified: libcxx/trunk/src/memory.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/memory.cpp (original)
+++ libcxx/trunk/src/memory.cpp Sat Jan  4 11:43:00 2014
@@ -208,7 +208,7 @@ align(size_t alignment, size_t size, voi
     if (size <= space)
     {
         char* p1 = static_cast<char*>(ptr);
-        char* p2 = (char*)((size_t)(p1 + (alignment - 1)) & -alignment);
+        char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment);
         size_t d = static_cast<size_t>(p2 - p1);
         if (d <= space - size)
         {

Modified: libcxx/trunk/src/new.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/new.cpp (original)
+++ libcxx/trunk/src/new.cpp Sat Jan  4 11:43:00 2014
@@ -167,7 +167,7 @@ set_new_handler(new_handler handler) _NO
 new_handler
 get_new_handler() _NOEXCEPT
 {
-    return __sync_fetch_and_add(&__new_handler, (new_handler)0);
+    return __sync_fetch_and_add(&__new_handler, nullptr);
 }
 
 #endif // !__GLIBCXX__

Modified: libcxx/trunk/src/stdexcept.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/stdexcept.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/stdexcept.cpp (original)
+++ libcxx/trunk/src/stdexcept.cpp Sat Jan  4 11:43:00 2014
@@ -46,7 +46,7 @@ private:
     static const std::ptrdiff_t offset = static_cast<std::ptrdiff_t>(2*sizeof(unused_t) +
                                                                        sizeof(count_t));
 
-    count_t& count() const _NOEXCEPT {return (count_t&)(*(str_ - sizeof(count_t)));}
+    count_t& count() const _NOEXCEPT {return *const_cast<count_t *>(reinterpret_cast<const count_t *>(str_ - sizeof(count_t)));}
 public:
     explicit __libcpp_nmstr(const char* msg);
     __libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT;
@@ -59,7 +59,7 @@ __libcpp_nmstr::__libcpp_nmstr(const cha
 {
     std::size_t len = strlen(msg);
     str_ = new char[len + 1 + offset];
-    unused_t* c = (unused_t*)str_;
+    unused_t* c = reinterpret_cast<unused_t*>(const_cast<char *>(str_));
     c[0] = c[1] = len;
     str_ += offset;
     count() = 0;
@@ -79,7 +79,7 @@ __libcpp_nmstr::operator=(const __libcpp
     const char* p = str_;
     str_ = s.str_;
     __sync_add_and_fetch(&count(), 1);
-    if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 0)
+    if (__sync_add_and_fetch(reinterpret_cast<const count_t*>(p-sizeof(count_t)), count_t(-1)) < 0)
         delete [] (p-offset);
     return *this;
 }
@@ -102,28 +102,29 @@ namespace std  // purposefully not using
 
 logic_error::logic_error(const string& msg)
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    ::new(&s) __libcpp_nmstr(msg.c_str());
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    ::new(s) __libcpp_nmstr(msg.c_str());
 }
 
 logic_error::logic_error(const char* msg)
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    ::new(&s) __libcpp_nmstr(msg);
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    ::new(s) __libcpp_nmstr(msg);
 }
 
 logic_error::logic_error(const logic_error& le) _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    ::new(&s) __libcpp_nmstr((const __libcpp_nmstr&)le.__imp_);
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    const __libcpp_nmstr *s2 = static_cast<const __libcpp_nmstr *>(le.__imp_);
+    ::new(s) __libcpp_nmstr(*s2);
 }
 
 logic_error&
 logic_error::operator=(const logic_error& le) _NOEXCEPT
 {
-    __libcpp_nmstr& s1 = (__libcpp_nmstr&)__imp_;
-    const __libcpp_nmstr& s2 = (const __libcpp_nmstr&)le.__imp_;
-    s1 = s2;
+    __libcpp_nmstr *s1 = static_cast<__libcpp_nmstr *>(__imp_);
+    const __libcpp_nmstr *s2 = static_cast<const __libcpp_nmstr *>(le.__imp_);
+    *s1 = *s2;
     return *this;
 }
 
@@ -131,43 +132,44 @@ logic_error::operator=(const logic_error
 
 logic_error::~logic_error() _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    s.~__libcpp_nmstr();
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    s->~__libcpp_nmstr();
 }
 
 const char*
 logic_error::what() const _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    return s.c_str();
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    return s->c_str();
 }
 
 #endif
 
 runtime_error::runtime_error(const string& msg)
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    ::new(&s) __libcpp_nmstr(msg.c_str());
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    ::new(s) __libcpp_nmstr(msg.c_str());
 }
 
 runtime_error::runtime_error(const char* msg)
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    ::new(&s) __libcpp_nmstr(msg);
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    ::new(s) __libcpp_nmstr(msg);
 }
 
 runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    ::new(&s) __libcpp_nmstr((const __libcpp_nmstr&)le.__imp_);
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    const __libcpp_nmstr *s2 = static_cast<const __libcpp_nmstr *>(le.__imp_);
+    ::new(s) __libcpp_nmstr(*s2);
 }
 
 runtime_error&
 runtime_error::operator=(const runtime_error& le) _NOEXCEPT
 {
-    __libcpp_nmstr& s1 = (__libcpp_nmstr&)__imp_;
-    const __libcpp_nmstr& s2 = (const __libcpp_nmstr&)le.__imp_;
-    s1 = s2;
+    __libcpp_nmstr *s1 = static_cast<__libcpp_nmstr *>(__imp_);
+    const __libcpp_nmstr *s2 = static_cast<const __libcpp_nmstr *>(le.__imp_);
+    *s1 = *s2;
     return *this;
 }
 
@@ -175,15 +177,15 @@ runtime_error::operator=(const runtime_e
 
 runtime_error::~runtime_error() _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    s.~__libcpp_nmstr();
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    s->~__libcpp_nmstr();
 }
 
 const char*
 runtime_error::what() const _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    return s.c_str();
+    __libcpp_nmstr *s = static_cast<__libcpp_nmstr *>(__imp_);
+    return s->c_str();
 }
 
 domain_error::~domain_error() _NOEXCEPT {}

Modified: libcxx/trunk/src/strstream.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/strstream.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/strstream.cpp (original)
+++ libcxx/trunk/src/strstream.cpp Sat Jan  4 11:43:00 2014
@@ -61,7 +61,7 @@ strstreambuf::strstreambuf(const char* _
       __palloc_(nullptr),
       __pfree_(nullptr)
 {
-    __init((char*)__gnext, __n, nullptr);
+    __init(const_cast<char *>(__gnext), __n, nullptr);
 }
 
 strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg)
@@ -70,7 +70,7 @@ strstreambuf::strstreambuf(signed char*
       __palloc_(nullptr),
       __pfree_(nullptr)
 {
-    __init((char*)__gnext, __n, (char*)__pbeg);
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
 }
 
 strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n)
@@ -79,7 +79,7 @@ strstreambuf::strstreambuf(const signed
       __palloc_(nullptr),
       __pfree_(nullptr)
 {
-    __init((char*)__gnext, __n, nullptr);
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
 }
 
 strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg)
@@ -88,7 +88,7 @@ strstreambuf::strstreambuf(unsigned char
       __palloc_(nullptr),
       __pfree_(nullptr)
 {
-    __init((char*)__gnext, __n, (char*)__pbeg);
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
 }
 
 strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n)
@@ -97,7 +97,7 @@ strstreambuf::strstreambuf(const unsigne
       __palloc_(nullptr),
       __pfree_(nullptr)
 {
-    __init((char*)__gnext, __n, nullptr);
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
 }
 
 strstreambuf::~strstreambuf()
@@ -186,7 +186,7 @@ strstreambuf::overflow(int_type __c)
     }
     *pptr() = static_cast<char>(__c);
     pbump(1);
-    return int_type((unsigned char)__c);
+    return int_type(static_cast<unsigned char>(__c));
 }
 
 strstreambuf::int_type
@@ -222,7 +222,7 @@ strstreambuf::underflow()
             return EOF;
         setg(eback(), gptr(), pptr());
     }
-    return int_type((unsigned char)*gptr());
+    return int_type(static_cast<unsigned char>(*gptr()));
 }
 
 strstreambuf::pos_type

Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=198505&r1=198504&r2=198505&view=diff
==============================================================================
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Sat Jan  4 11:43:00 2014
@@ -144,7 +144,7 @@ public:
     
     T* allocate(size_t __n)
         {return static_cast<T*>(::operator new(__n * sizeof(T)));}
-    void deallocate(T* __p, size_t) {::operator delete((void*)__p);}
+    void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));}
 
     size_t max_size() const {return size_t(~0) / sizeof(T);}
 };





More information about the cfe-commits mailing list