Fix llvm::BumpPtrAllocatorImpl::Reset()
[oota-llvm.git] / include / llvm / Support / Allocator.h
index f633857f46e53df02e34d7c20efae8cd7febecd4..f9b5cf22f97d42f69e3f321577dce572f5a2228f 100644 (file)
@@ -187,6 +187,9 @@ public:
   /// \brief Deallocate all but the current slab and reset the current pointer
   /// to the beginning of it, freeing all memory allocated so far.
   void Reset() {
+    DeallocateCustomSizedSlabs();
+    CustomSizedSlabs.clear();
+
     if (Slabs.empty())
       return;
 
@@ -198,8 +201,6 @@ public:
     // Deallocate all but the first slab, and deallocate all custom-sized slabs.
     DeallocateSlabs(std::next(Slabs.begin()), Slabs.end());
     Slabs.erase(std::next(Slabs.begin()), Slabs.end());
-    DeallocateCustomSizedSlabs();
-    CustomSizedSlabs.clear();
   }
 
   /// \brief Allocate space at the specified alignment.