Allow cstringmap to contain strings with nul characters in them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34062 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/CStringMap.cpp b/lib/Support/CStringMap.cpp
index 31b50d2..b145e2e 100644
--- a/lib/Support/CStringMap.cpp
+++ b/lib/Support/CStringMap.cpp
@@ -58,7 +58,7 @@
   unsigned ProbeAmt = 1;
   while (1) {
     ItemBucket &Bucket = TheTable[BucketNo];
-    void *BucketItem = Bucket.Item;
+    StringMapEntryBase *BucketItem = Bucket.Item;
     // If we found an empty bucket, this key isn't in the table yet, return it.
     if (BucketItem == 0) {
       Bucket.FullHashValue = FullHashValue;
@@ -73,8 +73,9 @@
       // Do the comparison like this because NameStart isn't necessarily
       // null-terminated!
       char *ItemStr = (char*)BucketItem+ItemSize;
-      if (strlen(ItemStr) == unsigned(NameEnd-NameStart) &&
-          memcmp(ItemStr, NameStart, (NameEnd-NameStart)) == 0) {
+      unsigned ItemStrLen = BucketItem->getKeyLength();
+      if (unsigned(NameEnd-NameStart) == ItemStrLen &&
+          memcmp(ItemStr, NameStart, ItemStrLen) == 0) {
         // We found a match!
         return BucketNo;
       }
@@ -131,7 +132,7 @@
 /// invoking Visitor.Visit for each of them.
 void CStringMapImpl::VisitEntries(const CStringMapVisitor &Visitor) const {
   for (ItemBucket *IB = TheTable, *E = TheTable+NumBuckets; IB != E; ++IB) {
-    if (void *Id = IB->Item)
+    if (StringMapEntryBase *Id = IB->Item)
       Visitor.Visit((char*)Id + ItemSize, Id);
   }
 }