5555#include  < ptrauth.h> 
5656#endif 
5757
58- 
59- template <typename  T>
60- static  inline 
61- T *
62- get_vtable (T *vtable) {
58+ template  <typename  T>
59+ static  inline  T* strip_vtable (T* vtable) {
6360#if  __has_feature(ptrauth_calls)
64-      vtable = ptrauth_strip (vtable, ptrauth_key_cxx_vtable_pointer);
61+   vtable = ptrauth_strip (vtable, ptrauth_key_cxx_vtable_pointer);
6562#endif 
66-      return  vtable;
63+   return  vtable;
6764}
6865
6966static  inline 
@@ -117,11 +114,10 @@ void dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr
117114        reinterpret_cast <const  uint8_t *>(vtable) + offset_to_ti_proxy;
118115    info->dynamic_type  = *(reinterpret_cast <const  __class_type_info* const *>(ptr_to_ti_proxy));
119116#else 
120-     void  **vtable = *static_cast <void  ** const  *>(static_ptr);
121-     vtable = get_vtable (vtable);
122-     info->offset_to_derived  = reinterpret_cast <ptrdiff_t >(vtable[-2 ]);
123-     info->dynamic_ptr  = static_cast <const  char *>(static_ptr) + info->offset_to_derived ;
124-     info->dynamic_type  = static_cast <const  __class_type_info*>(vtable[-1 ]);
117+   void ** vtable = strip_vtable (*static_cast <void ** const *>(static_ptr));
118+   info->offset_to_derived  = reinterpret_cast <ptrdiff_t >(vtable[-2 ]);
119+   info->dynamic_ptr  = static_cast <const  char *>(static_ptr) + info->offset_to_derived ;
120+   info->dynamic_type  = static_cast <const  __class_type_info*>(vtable[-1 ]);
125121#endif 
126122}
127123
@@ -576,8 +572,7 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
576572       find the layout.  */  
577573    offset_to_base = __offset_flags >> __offset_shift;
578574    if  (is_virtual) {
579-       const  char * vtable = *static_cast <const  char * const *>(adjustedPtr);
580-       vtable = get_vtable (vtable);
575+       const  char * vtable = strip_vtable (*static_cast <const  char * const *>(adjustedPtr));
581576      offset_to_base = update_offset_to_base (vtable, offset_to_base);
582577    }
583578  } else  if  (!is_virtual) {
@@ -1517,9 +1512,8 @@ __base_class_type_info::search_above_dst(__dynamic_cast_info* info,
15171512    ptrdiff_t  offset_to_base = __offset_flags >> __offset_shift;
15181513    if  (__offset_flags & __virtual_mask)
15191514    {
1520-         const  char * vtable = *static_cast <const  char *const *>(current_ptr);
1521-         vtable = get_vtable (vtable);
1522-         offset_to_base = update_offset_to_base (vtable, offset_to_base);
1515+       const  char * vtable = strip_vtable (*static_cast <const  char * const *>(current_ptr));
1516+       offset_to_base = update_offset_to_base (vtable, offset_to_base);
15231517    }
15241518    __base_type->search_above_dst (info, dst_ptr,
15251519                                  static_cast <const  char *>(current_ptr) + offset_to_base,
@@ -1538,9 +1532,8 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
15381532    ptrdiff_t  offset_to_base = __offset_flags >> __offset_shift;
15391533    if  (__offset_flags & __virtual_mask)
15401534    {
1541-         const  char * vtable = *static_cast <const  char *const *>(current_ptr);
1542-         vtable = get_vtable (vtable);
1543-         offset_to_base = update_offset_to_base (vtable, offset_to_base);
1535+       const  char * vtable = strip_vtable (*static_cast <const  char * const *>(current_ptr));
1536+       offset_to_base = update_offset_to_base (vtable, offset_to_base);
15441537    }
15451538    __base_type->search_below_dst (info,
15461539                                  static_cast <const  char *>(current_ptr) + offset_to_base,
0 commit comments