summaryrefslogtreecommitdiffstats
path: root/contrib/libcxxrt/dynamic_cast.cc
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-12-30 20:01:06 +0000
committerdim <dim@FreeBSD.org>2014-12-30 20:01:06 +0000
commit82d90d488027b4090723abca792814eb3ede87a4 (patch)
treef7082c2eee697d11362cdbb5491f757462e35ad8 /contrib/libcxxrt/dynamic_cast.cc
parenta1a2c6c54c310e3c91fc3b88eb17631255825698 (diff)
downloadFreeBSD-src-82d90d488027b4090723abca792814eb3ede87a4.zip
FreeBSD-src-82d90d488027b4090723abca792814eb3ede87a4.tar.gz
Import libcxxrt master 00bc29eb6513624824a6d7db2ebc768a4216a604.
Interesting fixes: 76584a0 Reorganize code to use only 32bit atomic ops for 32bit platforms 30d2ae5 Implement __cxa_throw_bad_array_new_length Reviewed by: bapt MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D1390
Diffstat (limited to 'contrib/libcxxrt/dynamic_cast.cc')
-rw-r--r--contrib/libcxxrt/dynamic_cast.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/libcxxrt/dynamic_cast.cc b/contrib/libcxxrt/dynamic_cast.cc
index 7a07e4c..6ae3a40 100644
--- a/contrib/libcxxrt/dynamic_cast.cc
+++ b/contrib/libcxxrt/dynamic_cast.cc
@@ -44,7 +44,7 @@ struct vtable_header
* Simple macro that does pointer arithmetic in bytes but returns a value of
* the same type as the original.
*/
-#define ADD_TO_PTR(x, off) (__typeof__(x))(((char*)x) + off)
+#define ADD_TO_PTR(x, off) reinterpret_cast<__typeof__(x)>(reinterpret_cast<char*>(x) + off)
bool std::type_info::__do_catch(std::type_info const *ex_type,
void **exception_object,
@@ -166,7 +166,7 @@ bool __vmi_class_type_info::__do_upcast(const __class_type_info *target,
if (info->isVirtual())
{
// Object's vtable
- ptrdiff_t *off = *(ptrdiff_t**)obj;
+ ptrdiff_t *off = *static_cast<ptrdiff_t**>(obj);
// Offset location in vtable
off = ADD_TO_PTR(off, offset);
offset = *off;
@@ -202,9 +202,9 @@ extern "C" void* __dynamic_cast(const void *sub,
const __class_type_info *dst,
ptrdiff_t src2dst_offset)
{
- char *vtable_location = *(char**)sub;
+ const char *vtable_location = *static_cast<const char * const *>(sub);
const vtable_header *header =
- (const vtable_header*)(vtable_location - sizeof(vtable_header));
- void *leaf = ADD_TO_PTR((void*)sub, header->leaf_offset);
+ reinterpret_cast<const vtable_header*>(vtable_location - sizeof(vtable_header));
+ void *leaf = ADD_TO_PTR(const_cast<void *>(sub), header->leaf_offset);
return header->type->cast_to(leaf, dst);
}
OpenPOWER on IntegriCloud