[llvm-commits] [llvm] r172469 - /llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp

David Greene greened at obbligato.org
Mon Jan 14 13:04:44 PST 2013


Author: greened
Date: Mon Jan 14 15:04:44 2013
New Revision: 172469

URL: http://llvm.org/viewvc/llvm-project?rev=172469&view=rev
Log:
Fix More Casts

Properly cast some more code that triggered cast-away-const errors.

Modified:
    llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp?rev=172469&r1=172468&r2=172469&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Mon Jan 14 15:04:44 2013
@@ -72,15 +72,20 @@
     /// getBlockAfter - Return the memory block immediately after this one.
     ///
     MemoryRangeHeader &getBlockAfter() const {
-      return *(MemoryRangeHeader*)((char*)this+BlockSize);
+      return *reinterpret_cast<MemoryRangeHeader *>(
+                reinterpret_cast<char*>(
+                  const_cast<MemoryRangeHeader *>(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<intptr_t *>(
+                            const_cast<MemoryRangeHeader *>(this))[-1];
+      return reinterpret_cast<FreeRangeHeader *>(
+               reinterpret_cast<char*>(
+                 const_cast<MemoryRangeHeader *>(this))-PrevSize);
     }
 
     /// FreeBlock - Turn an allocated block into a free block, adjusting





More information about the llvm-commits mailing list