summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/StringMap.cpp
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
commit846f95080c90242ed898b9a795d8d2a5ab4fe9dc (patch)
treece006903a081374df50451762f7b53260778160d /llvm/lib/Support/StringMap.cpp
parentbdc1b01217441962f3547b847c35b629e534638e (diff)
downloadbcm5719-llvm-846f95080c90242ed898b9a795d8d2a5ab4fe9dc.tar.gz
bcm5719-llvm-846f95080c90242ed898b9a795d8d2a5ab4fe9dc.zip
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! llvm-svn: 128567
Diffstat (limited to 'llvm/lib/Support/StringMap.cpp')
-rw-r--r--llvm/lib/Support/StringMap.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp
index f193aa42a44..a1ac512fa24 100644
--- a/llvm/lib/Support/StringMap.cpp
+++ b/llvm/lib/Support/StringMap.cpp
@@ -169,6 +169,8 @@ StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) {
TheTable[Bucket].Item = getTombstoneVal();
--NumItems;
++NumTombstones;
+ assert(NumItems + NumTombstones <= NumBuckets);
+
return Result;
}
@@ -224,4 +226,5 @@ void StringMapImpl::RehashTable() {
TheTable = NewTableArray;
NumBuckets = NewSize;
+ NumTombstones = 0;
}
OpenPOWER on IntegriCloud