Fix a bug in DenseMap::clear, where we never reset a tombstone
authorChris Lattner <sabre@nondot.org>
Sun, 5 Aug 2007 08:43:36 +0000 (08:43 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 5 Aug 2007 08:43:36 +0000 (08:43 +0000)
to EmptyKey.

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

include/llvm/ADT/DenseMap.h

index 8b25a82e6ac69b5d6954a3d4ddd9e394decd4b25..fd3f346891b45318b272a8f439b46490a7959220 100644 (file)
@@ -100,10 +100,12 @@ public:
     
     const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
     for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
-      if (P->first != EmptyKey && P->first != TombstoneKey) {
+      if (P->first != EmptyKey) {
+        if (P->first != TombstoneKey) {
+          P->second.~ValueT();
+          --NumEntries;
+        }
         P->first = EmptyKey;
-        P->second.~ValueT();
-        --NumEntries;
       }
     }
     assert(NumEntries == 0 && "Node count imbalance!");