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

Dmitri Gribenko gribozavr at gmail.com
Thu Jul 5 17:25:39 PDT 2012


Author: gribozavr
Date: Thu Jul  5 19:25:39 2012
New Revision: 159789

URL: http://llvm.org/viewvc/llvm-project?rev=159789&view=rev
Log:
Enable new[] on llvm::BumpPtrAllocator.

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=159789&r1=159788&r2=159789&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Thu Jul  5 19:25:39 2012
@@ -239,4 +239,21 @@
 
 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





More information about the llvm-commits mailing list