diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-30 18:32:51 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-30 18:32:51 +0000 |
commit | 03ef44991768b803ed5b210877ce0d83bf16fd93 (patch) | |
tree | 6efc42db0cf9cbf4c60113e3f5262c55fe54ab8e /lib/Support/StringMap.cpp | |
parent | e10fff6f8802d6ab4045d9d0bb22e6f37e6d3d0b (diff) |
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 'lib/Support/StringMap.cpp')
-rw-r--r-- | lib/Support/StringMap.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Support/StringMap.cpp b/lib/Support/StringMap.cpp index f193aa42a4..a1ac512fa2 100644 --- a/lib/Support/StringMap.cpp +++ b/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; } |