diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-02-18 12:09:51 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-02-18 12:09:51 +0000 |
commit | 3f213e7b3a6829a154d4e8ceb7d8689b389bd5dc (patch) | |
tree | ba9c46607076d86d28e413ff7b40378bc254ae28 /include | |
parent | 32d0b2a9e8fd29c12ceea164db953767dd199b1f (diff) |
Futureproof AttrBuild if we ever have more than 64 attr enum values.
Currently we're at 34. Bitset should compile into virtually the same code as
uint64_t here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/IR/Attributes.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index c0a34a01d0..380bc6a3e0 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -19,6 +19,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/Support/PointerLikeTypeTraits.h" +#include <bitset> #include <cassert> #include <map> #include <string> @@ -378,7 +379,7 @@ template<> struct DenseMapInfo<AttributeSet> { /// value, however, is not. So this can be used as a quick way to test for /// equality, presence of attributes, etc. class AttrBuilder { - uint64_t Attrs; + std::bitset<Attribute::EndAttrKinds> Attrs; std::map<std::string, std::string> TargetDepAttrs; uint64_t Alignment; uint64_t StackAlignment; @@ -422,9 +423,8 @@ public: /// \brief Return true if the builder has the specified attribute. bool contains(Attribute::AttrKind A) const { - assert((unsigned)A < 64 && A < Attribute::EndAttrKinds && - "Attribute out of range!"); - return Attrs & (1ULL << A); + assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!"); + return Attrs[A]; } /// \brief Return true if the builder has the specified target-dependent @@ -457,7 +457,7 @@ public: /// \brief Return true if the builder contains no target-independent /// attributes. - bool empty() const { return Attrs == 0; } + bool empty() const { return Attrs.none(); } // Iterators for target-dependent attributes. typedef std::pair<std::string, std::string> td_type; |