Fix PR13148, an inf-loop in StringMap.
authorChandler Carruth <chandlerc@gmail.com>
Tue, 19 Jun 2012 17:40:35 +0000 (17:40 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 19 Jun 2012 17:40:35 +0000 (17:40 +0000)
commit2a79116940012acaad9cc70efef79d7359f27513
tree08260362bb9c61609ed5ed672cdf0667300457e4
parent0fb9b9a46a55df07edab41517b12ac30cfcedbbc
Fix PR13148, an inf-loop in StringMap.

StringMap suffered from the same bug as DenseMap: when you explicitly
construct it with a small number of buckets, you can arrange for the
tombstone-based growth path to be followed when the number of buckets
was less than '8'. In that case, even with a full map, it would compare
'0' as not less than '0', and refuse to grow the table, leading to
inf-loops trying to find an empty bucket on the next insertion. The fix
is very simple: use '<=' as the comparison. The same fix was applied to
DenseMap as well during its recent refactoring.

Thanks to Alex Bolz for the great report and test case. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158725 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/StringMap.cpp
unittests/ADT/StringMapTest.cpp