[llvm-commits] [llvm] r52686 - /llvm/trunk/include/llvm/Support/Allocator.h

Dan Gohman gohman at apple.com
Tue Jun 24 10:49:26 PDT 2008


Author: djg
Date: Tue Jun 24 12:49:26 2008
New Revision: 52686

URL: http://llvm.org/viewvc/llvm-project?rev=52686&view=rev
Log:
Make Allocate<T>() return a T* instead of a void*. And use
static_cast instead of reinterpret_cast.

Modified:
    llvm/trunk/include/llvm/Support/Allocator.h

Modified: llvm/trunk/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=52686&r1=52685&r2=52686&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Tue Jun 24 12:49:26 2008
@@ -25,12 +25,14 @@
   ~MallocAllocator() {}
   
   void Reset() {}
+
   void *Allocate(size_t Size, size_t Alignment) { return malloc(Size); }
   
   template <typename T>
-  void *Allocate() { return reinterpret_cast<T*>(malloc(sizeof(T))); }
+  T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); }
   
   void Deallocate(void *Ptr) { free(Ptr); }
+
   void PrintStats() const {}
 };
 
@@ -45,15 +47,16 @@
   ~BumpPtrAllocator();
   
   void Reset();
+
   void *Allocate(size_t Size, size_t Alignment);
 
   template <typename T>
-  void *Allocate() { 
-    return reinterpret_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
+  T *Allocate() { 
+    return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
   }
-
   
   void Deallocate(void *Ptr) {}
+
   void PrintStats() const;
 };
 





More information about the llvm-commits mailing list