aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-03-30 18:32:51 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-03-30 18:32:51 +0000
commit03ef44991768b803ed5b210877ce0d83bf16fd93 (patch)
tree6efc42db0cf9cbf4c60113e3f5262c55fe54ab8e /include
parente10fff6f8802d6ab4045d9d0bb22e6f37e6d3d0b (diff)
downloadexternal_llvm-03ef44991768b803ed5b210877ce0d83bf16fd93.zip
external_llvm-03ef44991768b803ed5b210877ce0d83bf16fd93.tar.gz
external_llvm-03ef44991768b803ed5b210877ce0d83bf16fd93.tar.bz2
Reset StringMap's NumTombstones on clears and rehashes.
StringMap was not properly updating NumTombstones after a clear or rehash. This was not fatal until now because the table was growing faster than NumTombstones could, but with the previous change of preventing infinite growth of the table the invariant (NumItems + NumTombstones <= NumBuckets) stopped being observed, causing infinite loops in certain situations. Patch by José Fonseca! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128567 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/StringMap.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index f3d6b9f..907c72d 100644
--- a/include/llvm/ADT/StringMap.h
+++ b/include/llvm/ADT/StringMap.h
@@ -329,6 +329,7 @@ public:
--NumTombstones;
Bucket.Item = KeyValue;
++NumItems;
+ assert(NumItems + NumTombstones <= NumBuckets);
RehashTable();
return true;
@@ -348,6 +349,7 @@ public:
}
NumItems = 0;
+ NumTombstones = 0;
}
/// GetOrCreateValue - Look up the specified key in the table. If a value
@@ -367,6 +369,7 @@ public:
if (Bucket.Item == getTombstoneVal())
--NumTombstones;
++NumItems;
+ assert(NumItems + NumTombstones <= NumBuckets);
// Fill in the bucket for the hash table. The FullHashValue was already
// filled in by LookupBucketFor.