[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
Fri Apr 1 06:31:35 PDT 2022


aaron.ballman added a comment.

The changes here look correct to me, but they complicate the code a reasonable amount. I almost wonder whether we want to add a helper function (perhaps even to STLExtras.h?) along the lines of a cleaned up version of:

  template <typename EnumTy1, typename EnumTy2>
  auto addEnumValues(EnumTy1 LHS, EnumTy2 RHS) {
    return static_cast<std::underlying_type_t<EnumTy1>>(LHS) +
      static_cast<std::underlying_type_t<EnumTy2>>(RHS);
  }

(We'd probably want some `enable_if` magic to protect the interface a bit more as well). WDYT of something like that? (That change would require some unit testing coverage as well, but this strikes me as something we're likely to want to reuse given that the functionality is deprecated.)


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