|
9 | 9 | #ifndef LLVM_ADT_POINTERSUMTYPE_H |
10 | 10 | #define LLVM_ADT_POINTERSUMTYPE_H |
11 | 11 |
|
12 | | -#include "llvm/ADT/bit.h" |
13 | 12 | #include "llvm/ADT/DenseMapInfo.h" |
| 13 | +#include "llvm/ADT/bit.h" |
14 | 14 | #include "llvm/Support/PointerLikeTypeTraits.h" |
| 15 | +#include <algorithm> |
15 | 16 | #include <cassert> |
16 | 17 | #include <cstdint> |
17 | 18 | #include <type_traits> |
@@ -226,19 +227,13 @@ struct PointerSumTypeHelper : MemberTs... { |
226 | 227 | }; |
227 | 228 |
|
228 | 229 | // Next we need to compute the number of bits available for the discriminant |
229 | | - // by taking the min of the bits available for each member. Much of this |
230 | | - // would be amazingly easier with good constexpr support. |
231 | | - template <uintptr_t V, uintptr_t... Vs> |
232 | | - struct Min : std::integral_constant< |
233 | | - uintptr_t, (V < Min<Vs...>::value ? V : Min<Vs...>::value)> { |
234 | | - }; |
235 | | - template <uintptr_t V> |
236 | | - struct Min<V> : std::integral_constant<uintptr_t, V> {}; |
237 | | - enum { NumTagBits = Min<MemberTs::TraitsT::NumLowBitsAvailable...>::value }; |
| 230 | + // by taking the min of the bits available for each member. |
| 231 | + static constexpr int NumTagBits = |
| 232 | + std::min({MemberTs::TraitsT::NumLowBitsAvailable...}); |
238 | 233 |
|
239 | 234 | // Also compute the smallest discriminant and various masks for convenience. |
240 | 235 | constexpr static TagT MinTag = |
241 | | - static_cast<TagT>(Min<MemberTs::Tag...>::value); |
| 236 | + static_cast<TagT>(std::min({static_cast<TagT>(MemberTs::Tag)...})); |
242 | 237 | enum : uint64_t { |
243 | 238 | PointerMask = static_cast<uint64_t>(-1) << NumTagBits, |
244 | 239 | TagMask = ~PointerMask |
|
0 commit comments