BumpPtrAllocator: don't accept 0 for the alignment parameter
[oota-llvm.git] / include / llvm / Support / Allocator.h
index f39fd10b0245708b8c5666b601c717ada6c4fe97..5ac1ec7ecbc892b299e6255b423296d03da9b24c 100644 (file)
@@ -201,13 +201,11 @@ public:
 
   /// \brief Allocate space at the specified alignment.
   void *Allocate(size_t Size, size_t Alignment) {
+    assert(Alignment > 0 && "0-byte alignnment is not allowed. Use 1 instead.");
+
     // Keep track of how many bytes we've allocated.
     BytesAllocated += Size;
 
-    // 0-byte alignment means 1-byte alignment.
-    if (Alignment == 0)
-      Alignment = 1;
-
     // Allocate the aligned space, going forwards from CurPtr.
     char *Ptr = alignPtr(CurPtr, Alignment);