[libunwind] r339217 - [libunwind] Fix pointer-to-integer cast warnings on LLP64.

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 8 00:51:33 PDT 2018


Merged to 7.0 in r339222.

On Wed, Aug 8, 2018 at 6:21 AM, Charles Davis via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: cdavis
> Date: Tue Aug  7 21:21:24 2018
> New Revision: 339217
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339217&view=rev
> Log:
> [libunwind] Fix pointer-to-integer cast warnings on LLP64.
>
> Summary:
> `long` is too short on LLP64. We have to use `intptr_t` to
> avoid truncating pointers.
>
> Reviewers: mstorsjo, rnk, compnerd, smeenai
>
> Subscribers: christof, cfe-commits, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D50412
>
> Modified:
>     libunwind/trunk/src/UnwindLevel1-gcc-ext.c
>     libunwind/trunk/src/UnwindLevel1.c
>
> Modified: libunwind/trunk/src/UnwindLevel1-gcc-ext.c
> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindLevel1-gcc-ext.c?rev=339217&r1=339216&r2=339217&view=diff
> ==============================================================================
> --- libunwind/trunk/src/UnwindLevel1-gcc-ext.c (original)
> +++ libunwind/trunk/src/UnwindLevel1-gcc-ext.c Tue Aug  7 21:21:24 2018
> @@ -33,9 +33,9 @@ _Unwind_Resume_or_Rethrow(_Unwind_Except
>                         (void *)exception_object,
>                         (long)exception_object->unwinder_cache.reserved1);
>  #else
> -  _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%ld",
> +  _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR,
>                         (void *)exception_object,
> -                       (long)exception_object->private_1);
> +                       (intptr_t)exception_object->private_1);
>  #endif
>
>  #if defined(_LIBUNWIND_ARM_EHABI)
> @@ -92,9 +92,9 @@ _LIBUNWIND_EXPORT void *_Unwind_FindEncl
>    unw_proc_info_t info;
>    unw_getcontext(&uc);
>    unw_init_local(&cursor, &uc);
> -  unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(long) pc);
> +  unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);
>    if (unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
> -    return (void *)(long) info.start_ip;
> +    return (void *)(intptr_t) info.start_ip;
>    else
>      return NULL;
>  }
> @@ -190,14 +190,14 @@ _LIBUNWIND_EXPORT const void *_Unwind_Fi
>    unw_proc_info_t info;
>    unw_getcontext(&uc);
>    unw_init_local(&cursor, &uc);
> -  unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(long) pc);
> +  unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);
>    unw_get_proc_info(&cursor, &info);
>    bases->tbase = (uintptr_t)info.extra;
>    bases->dbase = 0; // dbase not used on Mac OS X
>    bases->func = (uintptr_t)info.start_ip;
>    _LIBUNWIND_TRACE_API("_Unwind_Find_FDE(pc=%p) => %p", pc,
> -                  (void *)(long) info.unwind_info);
> -  return (void *)(long) info.unwind_info;
> +                  (void *)(intptr_t) info.unwind_info);
> +  return (void *)(intptr_t) info.unwind_info;
>  }
>
>  /// Returns the CFA (call frame area, or stack pointer at start of function)
>
> Modified: libunwind/trunk/src/UnwindLevel1.c
> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindLevel1.c?rev=339217&r1=339216&r2=339217&view=diff
> ==============================================================================
> --- libunwind/trunk/src/UnwindLevel1.c (original)
> +++ libunwind/trunk/src/UnwindLevel1.c Tue Aug  7 21:21:24 2018
> @@ -287,7 +287,7 @@ unwind_phase2_forced(unw_context_t *uc,
>      // If there is a personality routine, tell it we are unwinding.
>      if (frameInfo.handler != 0) {
>        __personality_routine p =
> -          (__personality_routine)(long)(frameInfo.handler);
> +          (__personality_routine)(intptr_t)(frameInfo.handler);
>        _LIBUNWIND_TRACE_UNWINDING(
>            "unwind_phase2_forced(ex_ojb=%p): calling personality function %p",
>            (void *)exception_object, (void *)(uintptr_t)p);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list