diff --git a/llvm/include/llvm/ADT/PointerSumType.h b/llvm/include/llvm/ADT/PointerSumType.h index 57f045035a784..132eab58b112a 100644 --- a/llvm/include/llvm/ADT/PointerSumType.h +++ b/llvm/include/llvm/ADT/PointerSumType.h @@ -9,9 +9,10 @@ #ifndef LLVM_ADT_POINTERSUMTYPE_H #define LLVM_ADT_POINTERSUMTYPE_H -#include "llvm/ADT/bit.h" #include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/bit.h" #include "llvm/Support/PointerLikeTypeTraits.h" +#include #include #include #include @@ -226,19 +227,13 @@ struct PointerSumTypeHelper : MemberTs... { }; // Next we need to compute the number of bits available for the discriminant - // by taking the min of the bits available for each member. Much of this - // would be amazingly easier with good constexpr support. - template - struct Min : std::integral_constant< - uintptr_t, (V < Min::value ? V : Min::value)> { - }; - template - struct Min : std::integral_constant {}; - enum { NumTagBits = Min::value }; + // by taking the min of the bits available for each member. + static constexpr int NumTagBits = + std::min({MemberTs::TraitsT::NumLowBitsAvailable...}); // Also compute the smallest discriminant and various masks for convenience. constexpr static TagT MinTag = - static_cast(Min::value); + static_cast(std::min({static_cast(MemberTs::Tag)...})); enum : uint64_t { PointerMask = static_cast(-1) << NumTagBits, TagMask = ~PointerMask