diff --git a/llvm/include/llvm/MC/SubtargetFeature.h b/llvm/include/llvm/MC/SubtargetFeature.h --- a/llvm/include/llvm/MC/SubtargetFeature.h +++ b/llvm/include/llvm/MC/SubtargetFeature.h @@ -40,14 +40,11 @@ class FeatureBitset { static_assert((MAX_SUBTARGET_FEATURES % 64) == 0, "Should be a multiple of 64!"); - // This cannot be a std::array, operator[] is not constexpr until C++17. - uint64_t Bits[MAX_SUBTARGET_WORDS] = {}; + std::array Bits{}; protected: - constexpr FeatureBitset(const std::array &B) { - for (unsigned I = 0; I != B.size(); ++I) - Bits[I] = B[I]; - } + constexpr FeatureBitset(const std::array &B) + : Bits{B} {} public: constexpr FeatureBitset() = default; @@ -103,7 +100,7 @@ } constexpr FeatureBitset &operator^=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) { + for (unsigned I = 0, E = Bits.size(); I != E; ++I) { Bits[I] ^= RHS.Bits[I]; } return *this; @@ -115,7 +112,7 @@ } constexpr FeatureBitset &operator&=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) { + for (unsigned I = 0, E = Bits.size(); I != E; ++I) { Bits[I] &= RHS.Bits[I]; } return *this; @@ -127,7 +124,7 @@ } constexpr FeatureBitset &operator|=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) { + for (unsigned I = 0, E = Bits.size(); I != E; ++I) { Bits[I] |= RHS.Bits[I]; } return *this;