Avoid undefined behavior in DenseMap::shrink_and_clear(). Log2_32_Ceil(0)

returns 32. This change mirrors the corresponding code in
SmallDenseMap::shrink_and_clear().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Richard Smith 2012-08-14 02:56:51 +00:00
parent a61d3a98c4
commit b8ea08ca8c

View File

@ -617,8 +617,9 @@ public:
this->destroyAll();
// Reduce the number of buckets.
unsigned NewNumBuckets
= std::max(64, 1 << (Log2_32_Ceil(OldNumEntries) + 1));
unsigned NewNumBuckets = 0;
if (OldNumEntries)
NewNumBuckets = std::max(64, 1 << (Log2_32_Ceil(OldNumEntries) + 1));
if (NewNumBuckets == NumBuckets) {
this->BaseT::initEmpty();
return;