Provide basic type safety for array_pod_sort comparators.
[oota-llvm.git] / include / llvm / Support / Recycler.h
index d8f8c78941429fbca8056a515e34001ba173cf73..bcc561db2d5cbcf484ef52a0f01a84bfa981cb2f 100644 (file)
 
 #include "llvm/ADT/ilist.h"
 #include "llvm/Support/AlignOf.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 
 namespace llvm {
 
+class BumpPtrAllocator;
+
 /// PrintRecyclingAllocatorStats - Helper for RecyclingAllocator for
 /// printing statistics.
 ///
@@ -52,7 +55,7 @@ struct ilist_traits<RecyclerStruct> :
   static void noteHead(RecyclerStruct*, RecyclerStruct*) {}
 
   static void deleteNode(RecyclerStruct *) {
-    assert(0 && "Recycler's ilist_traits shouldn't see a deleteNode call!");
+    llvm_unreachable("Recycler's ilist_traits shouldn't see a deleteNode call!");
   }
 };
 
@@ -86,6 +89,15 @@ public:
     }
   }
 
+  /// Special case for BumpPtrAllocator which has an empty Deallocate()
+  /// function.
+  ///
+  /// There is no need to traverse the free list, pulling all the objects into
+  /// cache.
+  void clear(BumpPtrAllocator&) {
+    FreeList.clearAndLeakNodesUnsafely();
+  }
+
   template<class SubClass, class AllocatorType>
   SubClass *Allocate(AllocatorType &Allocator) {
     assert(sizeof(SubClass) <= Size &&