55
55
#include < ptrauth.h>
56
56
#endif
57
57
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) {
63
60
#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);
65
62
#endif
66
- return vtable;
63
+ return vtable;
67
64
}
68
65
69
66
static inline
@@ -117,11 +114,10 @@ void dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr
117
114
reinterpret_cast <const uint8_t *>(vtable) + offset_to_ti_proxy;
118
115
info->dynamic_type = *(reinterpret_cast <const __class_type_info* const *>(ptr_to_ti_proxy));
119
116
#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 ]);
125
121
#endif
126
122
}
127
123
@@ -576,8 +572,7 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
576
572
find the layout. */
577
573
offset_to_base = __offset_flags >> __offset_shift;
578
574
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));
581
576
offset_to_base = update_offset_to_base (vtable, offset_to_base);
582
577
}
583
578
} else if (!is_virtual) {
@@ -1517,9 +1512,8 @@ __base_class_type_info::search_above_dst(__dynamic_cast_info* info,
1517
1512
ptrdiff_t offset_to_base = __offset_flags >> __offset_shift;
1518
1513
if (__offset_flags & __virtual_mask)
1519
1514
{
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);
1523
1517
}
1524
1518
__base_type->search_above_dst (info, dst_ptr,
1525
1519
static_cast <const char *>(current_ptr) + offset_to_base,
@@ -1538,9 +1532,8 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
1538
1532
ptrdiff_t offset_to_base = __offset_flags >> __offset_shift;
1539
1533
if (__offset_flags & __virtual_mask)
1540
1534
{
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);
1544
1537
}
1545
1538
__base_type->search_below_dst (info,
1546
1539
static_cast <const char *>(current_ptr) + offset_to_base,
0 commit comments