[libcxx-commits] [libcxx] 8d5c0b8 - [libc++] Remove unnecessary reinterpret_cast from typeinfo

Fanbo Meng via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 28 07:00:39 PDT 2021


Author: Jonathan Crowther
Date: 2021-06-28T10:00:33-04:00
New Revision: 8d5c0b8768f729d48e25251755ec12cfd785c934

URL: https://github.com/llvm/llvm-project/commit/8d5c0b8768f729d48e25251755ec12cfd785c934
DIFF: https://github.com/llvm/llvm-project/commit/8d5c0b8768f729d48e25251755ec12cfd785c934.diff

LOG: [libc++] Remove unnecessary reinterpret_cast from typeinfo

In typeinfo there is a reinterpret_cast between a uintptr_t and size_t. These are two integer types and therefore a reinterpret_cast is not right for this situation. It looks like it may have been copied and pasted from above in the file. An implicit cast works in it's place.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D104814

Added: 
    

Modified: 
    libcxx/include/typeinfo

Removed: 
    


################################################################################
diff  --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index 65ce53a0e9d7..6026038ba5f9 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -249,7 +249,7 @@ struct __type_info_implementations {
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
     static size_t __hash(__type_name_t __v) _NOEXCEPT {
       if (__is_type_name_unique(__v))
-        return reinterpret_cast<size_t>(__v);
+        return __v;
       return __non_unique_impl::__hash(__type_name_to_string(__v));
     }
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE


        


More information about the libcxx-commits mailing list