From f4dc289cea5dbfa272b54a8436a6bda6b226cee2 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 24 Jun 2008 17:49:26 +0000 Subject: [PATCH] Make Allocate() return a T* instead of a void*. And use static_cast instead of reinterpret_cast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52686 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Allocator.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 33cdca13e64..14211488a59 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -25,12 +25,14 @@ public: ~MallocAllocator() {} void Reset() {} + void *Allocate(size_t Size, size_t Alignment) { return malloc(Size); } template - void *Allocate() { return reinterpret_cast(malloc(sizeof(T))); } + T *Allocate() { return static_cast(malloc(sizeof(T))); } void Deallocate(void *Ptr) { free(Ptr); } + void PrintStats() const {} }; @@ -45,15 +47,16 @@ public: ~BumpPtrAllocator(); void Reset(); + void *Allocate(size_t Size, size_t Alignment); template - void *Allocate() { - return reinterpret_cast(Allocate(sizeof(T),AlignOf::Alignment)); + T *Allocate() { + return static_cast(Allocate(sizeof(T),AlignOf::Alignment)); } - void Deallocate(void *Ptr) {} + void PrintStats() const; };