[llvm] r284985 - [ADT] static_assert that SmallDenseMap is instantiated with a power-of-two number of inline buckets.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 24 09:06:53 PDT 2016
Author: jlebar
Date: Mon Oct 24 11:06:53 2016
New Revision: 284985
URL: http://llvm.org/viewvc/llvm-project?rev=284985&view=rev
Log:
[ADT] static_assert that SmallDenseMap is instantiated with a power-of-two number of inline buckets.
Summary:
If you try to instantiate it with a non-power-of-two buckets, DenseMap
will assert at runtime (!) if we ever outgrow our inline storage.
I believe using a constexpr function inside of a static_assert is safe
now that we've unsupported MSVC 2013 and GCC < 4.8.
Reviewers: bkramer, qcolombet, escha
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25900
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=284985&r1=284984&r2=284985&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Mon Oct 24 11:06:53 2016
@@ -742,6 +742,8 @@ class SmallDenseMap
// simplicity of referring to them.
typedef DenseMapBase<SmallDenseMap, KeyT, ValueT, KeyInfoT, BucketT> BaseT;
friend class DenseMapBase<SmallDenseMap, KeyT, ValueT, KeyInfoT, BucketT>;
+ static_assert(isPowerOf2_64(InlineBuckets),
+ "InlineBuckets must be a power of 2.");
unsigned Small : 1;
unsigned NumEntries : 31;
More information about the llvm-commits
mailing list