aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-06-24 17:49:26 +0000
committerDan Gohman <gohman@apple.com>2008-06-24 17:49:26 +0000
commitf4dc289cea5dbfa272b54a8436a6bda6b226cee2 (patch)
tree170c603ae90f74c5bcfcd5412602472532d5dda7
parentb70e4528200568b500a1ad4bff40686741070b68 (diff)
Make Allocate<T>() 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
-rw-r--r--include/llvm/Support/Allocator.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h
index 33cdca13e6..14211488a5 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 <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 @@ public:
~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;
};