[PATCH] D122808: [clang] Fix warnings when `-Wdeprecated-enum-enum-conversion` is enabled

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 4 11:47:50 PDT 2022


aaron.ballman added a comment.

In D122808#3425703 <https://reviews.llvm.org/D122808#3425703>, @antoniofrighetto wrote:

> Looks definitely better! How about this slightly changed version protecting the interface?
>
>   /// Helper which adds two underlying types of enumeration type.
>   template <typename EnumTy1,
>             typename EnumTy2,
>             typename UT1 = std::enable_if_t<std::is_enum_v<EnumTy1>, std::underlying_type_t<EnumTy1>>,
>             typename UT2 = std::enable_if_t<std::is_enum_v<EnumTy2>, std::underlying_type_t<EnumTy2>>>
>   constexpr auto addEnumValues(EnumTy1 LHS, EnumTy2 RHS) {
>     return static_cast<UT1>(LHS) + static_cast<UT2>(RHS);
>   }
>
> I feel like this is something we may wish to readopt in the future for other similar cases as well  (e.g., `-Wdeprecated-anon-enum-enum-conversion` in `Comment.h`).

I think that's a great interface for it!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122808/new/

https://reviews.llvm.org/D122808



More information about the cfe-commits mailing list