[libcxx-commits] [PATCH] D104814: [libc++] Remove unnecessary reinterpret_cast from typeinfo

Jonathan Crowther via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 23 13:38:09 PDT 2021


Jonathan.Crowther created this revision.
Jonathan.Crowther added reviewers: abhina.sreeskantharajan, EricWF, ldionne, zibi, muiez, SeanP.
Herald added a subscriber: smeenai.
Jonathan.Crowther requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104814

Files:
  libcxx/include/typeinfo


Index: libcxx/include/typeinfo
===================================================================
--- libcxx/include/typeinfo
+++ libcxx/include/typeinfo
@@ -253,7 +253,7 @@
     _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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104814.354068.patch
Type: text/x-patch
Size: 521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210623/5890a9c0/attachment.bin>


More information about the libcxx-commits mailing list