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

Duncan Sands baldrick at free.fr
Fri Jul 6 00:49:38 PDT 2012


Hi Dmitri,

> --- 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;
> +  };

is this ugly struct really needed?  If so, maybe it should be placed in its own
header file somewhere and shared with code like SmallVector.h that does the same
trick.

Ciao, Duncan.

> +  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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>





More information about the llvm-commits mailing list