aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-07-06 00:25:39 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-07-06 00:25:39 +0000
commit0da21789b3b1b51dbdf3e6ea5682a8508e747ca9 (patch)
treed3b3757728edd3ef4b611f5ca6410f959ce016f8
parent244a84ee57cc73509a0e85cc92585cb567d0b72c (diff)
downloadexternal_llvm-0da21789b3b1b51dbdf3e6ea5682a8508e747ca9.zip
external_llvm-0da21789b3b1b51dbdf3e6ea5682a8508e747ca9.tar.gz
external_llvm-0da21789b3b1b51dbdf3e6ea5682a8508e747ca9.tar.bz2
Enable new[] on llvm::BumpPtrAllocator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159789 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Support/Allocator.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h
index a2ad24f..c2dd75d 100644
--- a/include/llvm/Support/Allocator.h
+++ b/include/llvm/Support/Allocator.h
@@ -239,4 +239,21 @@ inline void *operator new(size_t Size, llvm::BumpPtrAllocator &Allocator) {
inline void operator delete(void *, llvm::BumpPtrAllocator &) {}
+inline void *operator new[](size_t Size, llvm::BumpPtrAllocator &Allocator) {
+ struct S {
+ char c;
+ union {
+ double D;
+ long double LD;
+ long long L;
+ void *P;
+ } x;
+ };
+ return Allocator.Allocate(Size, std::min((size_t)llvm::NextPowerOf2(Size),
+ offsetof(S, x)));
+}
+
+inline void operator delete[](void *Ptr, llvm::BumpPtrAllocator &C, size_t) {
+}
+
#endif // LLVM_SUPPORT_ALLOCATOR_H