Disable the string map copy ctor and assignment operators,
authorChris Lattner <sabre@nondot.org>
Sun, 22 Jul 2007 20:08:01 +0000 (20:08 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 Jul 2007 20:08:01 +0000 (20:08 +0000)
they don't do the right thing.

Implement StringMap::erase.

Fix a nasty bug in the default ctor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40395 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringMap.h

index cb1dd9f132991d13af3201446c67c36181797b43..72108e97e4fb54d8b958d2521331cafe79831084 100644 (file)
@@ -55,7 +55,13 @@ protected:
   unsigned NumTombstones;
   unsigned ItemSize;
 protected:
-  StringMapImpl(unsigned itemSize) : ItemSize(itemSize) { init(16); }
+  StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {
+    // Initialize the map with zero buckets to allocation.
+    TheTable = 0;
+    NumBuckets = 0;
+    NumItems = 0;
+    NumTombstones = 0;
+  }
   StringMapImpl(unsigned InitSize, unsigned ItemSize);
   void RehashTable();
   
@@ -274,6 +280,12 @@ public:
     RemoveKey(KeyValue);
   }
   
+  void erase(iterator I) {
+    MapEntryTy &V = *I;
+    remove(&V);
+    V.Destroy(Allocator);
+  }
+  
   ~StringMap() {
     for (ItemBucket *I = TheTable, *E = TheTable+NumBuckets; I != E; ++I) {
       if (I->Item && I->Item != getTombstoneVal())
@@ -281,6 +293,9 @@ public:
     }
     free(TheTable);
   }
+private:
+  StringMap(const StringMap &);  // FIXME: Implement.
+  void operator=(const StringMap &);  // FIXME: Implement.
 };