diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index 5b20d6bd38262..658f26249122a 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -161,12 +161,10 @@ using TypeAtIndex = std::tuple_element_t>; /// Helper which adds two underlying types of enumeration type. /// Implicit conversion to a common type is accepted. template ::value, - std::underlying_type_t>, - typename UT2 = std::enable_if_t::value, - std::underlying_type_t>> + typename = std::enable_if_t && + std::is_enum_v>> constexpr auto addEnumValues(EnumTy1 LHS, EnumTy2 RHS) { - return static_cast(LHS) + static_cast(RHS); + return llvm::to_underlying(LHS) + llvm::to_underlying(RHS); } //===----------------------------------------------------------------------===//