From 8e46d89df452aac4a64ca562d3320b524b528d55 Mon Sep 17 00:00:00 2001 From: David Greene Date: Mon, 14 Jan 2013 21:04:44 +0000 Subject: [PATCH] Fix More Casts Properly cast some more code that triggered cast-away-const errors. llvm-svn: 172469 --- llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp index 353bebf84ab9..66aeb772ddc3 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp @@ -72,15 +72,20 @@ namespace { /// getBlockAfter - Return the memory block immediately after this one. /// MemoryRangeHeader &getBlockAfter() const { - return *(MemoryRangeHeader*)((char*)this+BlockSize); + return *reinterpret_cast( + reinterpret_cast( + const_cast(this))+BlockSize); } /// getFreeBlockBefore - If the block before this one is free, return it, /// otherwise return null. FreeRangeHeader *getFreeBlockBefore() const { if (PrevAllocated) return 0; - intptr_t PrevSize = ((intptr_t *)this)[-1]; - return (FreeRangeHeader*)((char*)this-PrevSize); + intptr_t PrevSize = reinterpret_cast( + const_cast(this))[-1]; + return reinterpret_cast( + reinterpret_cast( + const_cast(this))-PrevSize); } /// FreeBlock - Turn an allocated block into a free block, adjusting