[llvm] r183216 - Preserve const correctness.

dag at cray.com dag at cray.com
Tue Jun 4 09:09:22 PDT 2013


Benjamin Kramer <benny.kra at googlemail.com> writes:

> Author: d0k
> Date: Tue Jun  4 04:09:15 2013
> New Revision: 183216
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183216&view=rev
> Log:
> Preserve const correctness.
>
> GCC complains about casting away const.
>
> Modified:
>     llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp?rev=183216&r1=183215&r2=183216&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp Tue Jun  4 04:09:15 2013
> @@ -45,11 +45,11 @@ extern "C" void __register_frame(void*);
>  
>  static const char *processFDE(const char *Entry) {
>    const char *P = Entry;
> -  uint32_t Length = *((uint32_t*)P);
> +  uint32_t Length = *((const uint32_t *)P);
>    P += 4;
> -  uint32_t Offset = *((uint32_t*)P);
> +  uint32_t Offset = *((const uint32_t *)P);
>    if (Offset != 0)
> -    __register_frame((void*)Entry);
> +    __register_frame(const_cast<char *>(Entry));

The patch LGTM, but I wonder about this last statement.  Should Entry
really be const if it is passed to a function taking non-const.  Your
patch should be able to go ahead.  I'm wondering about the larger
question and whether this needs investigation.

                         -David



More information about the llvm-commits mailing list