Make the assignment operator for SmallPtrSet return a reference, and fix a long-stand...
[oota-llvm.git] / lib / Support / Allocator.cpp
index 7e7477357fe431bcb9f64d52ee70b129fc2a5db7..234fd41b73832199fc1d6b4c0aa510570ce073b9 100644 (file)
@@ -13,7 +13,8 @@
 
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/DataTypes.h"
-#include <iostream>
+#include "llvm/Support/Streams.h"
+#include <ostream>
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -92,7 +93,10 @@ BumpPtrAllocator::~BumpPtrAllocator() {
 }
 
 void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
-  return ((MemRegion*)TheMemory)->Allocate(Size, Align,(MemRegion**)&TheMemory);
+  MemRegion *MRP = (MemRegion*)TheMemory;
+  void *Ptr = MRP->Allocate(Size, Align, &MRP);
+  TheMemory = MRP;
+  return Ptr;
 }
 
 void BumpPtrAllocator::PrintStats() const {
@@ -102,6 +106,6 @@ void BumpPtrAllocator::PrintStats() const {
   for (; R; R = R->getNext(), ++NumRegions)
     BytesUsed += R->getNumBytesAllocated();
 
-  std::cerr << "\nNumber of memory regions: " << NumRegions << "\n";
-  std::cerr << "Bytes allocated: " << BytesUsed << "\n";
+  cerr << "\nNumber of memory regions: " << NumRegions << "\n";
+  cerr << "Bytes allocated: " << BytesUsed << "\n";
 }