[llvm-commits] [llvm] r161829 - /llvm/trunk/include/llvm/ADT/DenseMap.h
Richard Smith
richard-llvm at metafoo.co.uk
Mon Aug 13 19:56:52 PDT 2012
Author: rsmith
Date: Mon Aug 13 21:56:51 2012
New Revision: 161829
URL: http://llvm.org/viewvc/llvm-project?rev=161829&view=rev
Log:
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().
Modified:
llvm/trunk/include/llvm/ADT/DenseMap.h
Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=161829&r1=161828&r2=161829&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Mon Aug 13 21:56:51 2012
@@ -617,8 +617,9 @@
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;
More information about the llvm-commits
mailing list