[llvm] r259257 - Fix the MSVC build by moving static asserts into constructors
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 14:40:22 PST 2016
Author: rnk
Date: Fri Jan 29 16:40:22 2016
New Revision: 259257
URL: http://llvm.org/viewvc/llvm-project?rev=259257&view=rev
Log:
Fix the MSVC build by moving static asserts into constructors
Apparently MSVC won't allow you to ask for the sizeof() a data member at
class scope.
Modified:
llvm/trunk/lib/IR/AttributeImpl.h
Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=259257&r1=259256&r2=259257&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Fri Jan 29 16:40:22 2016
@@ -152,11 +152,11 @@ class AttributeSetNode final
unsigned NumAttrs; ///< Number of attributes in this node.
/// Bitset with a bit for each available attribute Attribute::AttrKind.
uint64_t AvailableAttrs;
- static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs)*CHAR_BIT,
- "Too many attributes for AvailableAttrs");
AttributeSetNode(ArrayRef<Attribute> Attrs)
: NumAttrs(Attrs.size()), AvailableAttrs(0) {
+ static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs) * CHAR_BIT,
+ "Too many attributes for AvailableAttrs");
// There's memory after the node where we can store the entries in.
std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects<Attribute>());
@@ -218,9 +218,6 @@ private:
unsigned NumAttrs; ///< Number of entries in this set.
/// Bitset with a bit for each available attribute Attribute::AttrKind.
uint64_t AvailableFunctionAttrs;
- static_assert(Attribute::EndAttrKinds
- <= sizeof(AvailableFunctionAttrs)*CHAR_BIT,
- "Too many attributes");
// Helper fn for TrailingObjects class.
size_t numTrailingObjects(OverloadToken<IndexAttrPair>) { return NumAttrs; }
@@ -237,6 +234,9 @@ public:
AttributeSetImpl(LLVMContext &C,
ArrayRef<std::pair<unsigned, AttributeSetNode *> > Attrs)
: Context(C), NumAttrs(Attrs.size()), AvailableFunctionAttrs(0) {
+ static_assert(Attribute::EndAttrKinds <=
+ sizeof(AvailableFunctionAttrs) * CHAR_BIT,
+ "Too many attributes");
#ifndef NDEBUG
if (Attrs.size() >= 2) {
More information about the llvm-commits
mailing list