@@ -442,6 +442,16 @@ class RelativeDirectPointerImpl {
442
442
return reinterpret_cast <PointerTy>(absolute);
443
443
}
444
444
445
+ void *getWithoutCast () const & {
446
+ // Check for null.
447
+ if (Nullable && RelativeOffset == 0 )
448
+ return nullptr ;
449
+
450
+ // The value is addressed relative to `this`.
451
+ uintptr_t absolute = detail::applyRelativeOffset (this , RelativeOffset);
452
+ return reinterpret_cast <void *>(absolute);
453
+ }
454
+
445
455
// / Apply the offset to a parameter, instead of `this`.
446
456
PointerTy getRelative (void *base) const & {
447
457
// Check for null.
@@ -511,26 +521,27 @@ class RelativeDirectPointer<T, Nullable, Offset,
511
521
}
512
522
513
523
typename super::PointerTy get () const & {
514
- auto ptr = this ->super ::get ();
524
+ void * ptr = this ->super ::getWithoutCast ();
515
525
#if SWIFT_PTRAUTH
516
526
if (Nullable && !ptr)
517
- return ptr;
518
- return ptrauth_sign_unauthenticated (ptr, ptrauth_key_function_pointer, 0 );
527
+ return nullptr ;
528
+ return reinterpret_cast <T *>(
529
+ ptrauth_sign_unauthenticated (ptr, ptrauth_key_function_pointer, 0 ));
519
530
#else
520
- return ptr;
531
+ return reinterpret_cast <T *>( ptr) ;
521
532
#endif
522
533
}
523
534
524
535
operator typename super::PointerTy () const & {
525
536
return this ->get ();
526
537
}
527
538
528
- template <typename ...ArgTy>
529
- typename std::result_of<T* (ArgTy...)>::type operator ()(ArgTy...arg) const {
539
+ template <typename ... ArgTy>
540
+ typename std::result_of<T * (ArgTy...)>::type operator ()(ArgTy... arg) const {
530
541
#if SWIFT_PTRAUTH
531
- return ptrauth_sign_unauthenticated ( this ->super ::get (),
532
- ptrauth_key_function_pointer,
533
- 0 )(std::forward<ArgTy>(arg)...);
542
+ void *ptr = this ->super ::getWithoutCast ();
543
+ return reinterpret_cast <T *>( ptrauth_sign_unauthenticated (
544
+ ptr, ptrauth_key_function_pointer, 0 ) )(std::forward<ArgTy>(arg)...);
534
545
#else
535
546
return this ->super ::get ()(std::forward<ArgTy>(arg)...);
536
547
#endif
0 commit comments