[llvm-commits] [support] r40398 - /support/trunk/include/llvm/ADT/StringMap.h

Reid Spencer rspencer at reidspencer.com
Sun Jul 22 13:30:37 PDT 2007


Author: reid
Date: Sun Jul 22 15:30:36 2007
New Revision: 40398

URL: http://llvm.org/viewvc/llvm-project?rev=40398&view=rev
Log:
Migrate changes from llvm directory:

Disable the string map copy ctor and assignment operators,
they don't do the right thing.  

Implement StringMap::erase.

Fix a nasty bug in the default ctor.


Modified:
    support/trunk/include/llvm/ADT/StringMap.h

Modified: support/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/support/trunk/include/llvm/ADT/StringMap.h?rev=40398&r1=40397&r2=40398&view=diff

==============================================================================
--- support/trunk/include/llvm/ADT/StringMap.h (original)
+++ support/trunk/include/llvm/ADT/StringMap.h Sun Jul 22 15:30:36 2007
@@ -55,7 +55,13 @@
   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 @@
     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 @@
     }
     free(TheTable);
   }
+private:
+  StringMap(const StringMap &);  // FIXME: Implement.
+  void operator=(const StringMap &);  // FIXME: Implement.
 };
   
 





More information about the llvm-commits mailing list