Remove bogus assertion. This unbreaks mingw, where ConstantSDNode
[oota-llvm.git] / include / llvm / ADT / DenseMap.h
index b29c69156277cc0ea5a52702430d837d37761d65..e584973e4f177dc8294a5ef5e0f49c161d450b6b 100644 (file)
@@ -82,7 +82,7 @@ public:
         P->second.~ValueT();
       P->first.~KeyT();
     }
-    delete[] reinterpret_cast<char*>(Buckets);
+    operator delete(Buckets);
   }
   
   typedef DenseMapIterator<KeyT, ValueT, KeyInfoT> iterator;
@@ -147,14 +147,16 @@ public:
     return end();
   }
   
-  bool insert(const std::pair<KeyT, ValueT> &KV) {
+  std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) {
     BucketT *TheBucket;
     if (LookupBucketFor(KV.first, TheBucket))
-      return false; // Already in map.
+      return std::make_pair(iterator(TheBucket, Buckets+NumBuckets),
+                            false); // Already in map.
     
     // Otherwise, insert the new element.
-    InsertIntoBucket(KV.first, KV.second, TheBucket);
-    return true;
+    TheBucket = InsertIntoBucket(KV.first, KV.second, TheBucket);
+    return std::make_pair(iterator(TheBucket, Buckets+NumBuckets),
+                          true);
   }
   
   bool erase(const KeyT &Val) {
@@ -210,15 +212,15 @@ private:
     NumTombstones = other.NumTombstones;
     
     if (NumBuckets)
-      delete[] reinterpret_cast<char*>(Buckets);
-    Buckets = reinterpret_cast<BucketT*>(new char[sizeof(BucketT) *
-                                                  other.NumBuckets]);
+      operator delete(Buckets);
+    Buckets = static_cast<BucketT*>(operator new(sizeof(BucketT) *
+                                                 other.NumBuckets));
     
     if (KeyInfoT::isPod() && ValueInfoT::isPod())
       memcpy(Buckets, other.Buckets, other.NumBuckets * sizeof(BucketT));
     else
       for (size_t i = 0; i < other.NumBuckets; ++i) {
-        new (Buckets[i].first) KeyT(other.Buckets[i].first);
+        new (&Buckets[i].first) KeyT(other.Buckets[i].first);
         if (!KeyInfoT::isEqual(Buckets[i].first, getEmptyKey()) &&
             !KeyInfoT::isEqual(Buckets[i].first, getTombstoneKey()))
           new (&Buckets[i].second) ValueT(other.Buckets[i].second);
@@ -315,7 +317,7 @@ private:
     NumBuckets = InitBuckets;
     assert(InitBuckets && (InitBuckets & (InitBuckets-1)) == 0 &&
            "# initial buckets must be a power of two!");
-    Buckets = reinterpret_cast<BucketT*>(new char[sizeof(BucketT)*InitBuckets]);
+    Buckets = static_cast<BucketT*>(operator new(sizeof(BucketT)*InitBuckets));
     // Initialize all the keys to EmptyKey.
     const KeyT EmptyKey = getEmptyKey();
     for (unsigned i = 0; i != InitBuckets; ++i)
@@ -330,7 +332,7 @@ private:
     while (NumBuckets <= AtLeast)
       NumBuckets <<= 1;
     NumTombstones = 0;
-    Buckets = reinterpret_cast<BucketT*>(new char[sizeof(BucketT)*NumBuckets]);
+    Buckets = static_cast<BucketT*>(operator new(sizeof(BucketT)*NumBuckets));
 
     // Initialize all the keys to EmptyKey.
     const KeyT EmptyKey = getEmptyKey();
@@ -357,7 +359,7 @@ private:
     }
     
     // Free the old table.
-    delete[] reinterpret_cast<char*>(OldBuckets);
+    operator delete(OldBuckets);
   }
   
   void shrink_and_clear() {
@@ -368,7 +370,7 @@ private:
     NumBuckets = NumEntries > 32 ? 1 << (Log2_32_Ceil(NumEntries) + 1)
                                  : 64;
     NumTombstones = 0;
-    Buckets = reinterpret_cast<BucketT*>(new char[sizeof(BucketT)*NumBuckets]);
+    Buckets = static_cast<BucketT*>(operator new(sizeof(BucketT)*NumBuckets));
 
     // Initialize all the keys to EmptyKey.
     const KeyT EmptyKey = getEmptyKey();
@@ -387,7 +389,7 @@ private:
     }
     
     // Free the old table.
-    delete[] reinterpret_cast<char*>(OldBuckets);
+    operator delete(OldBuckets);
     
     NumEntries = 0;
   }