Skip to content

[ADT] Remove is_scoped_enum_v #138134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions clang/include/clang/Basic/Diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1429,16 +1429,19 @@ operator<<(const StreamingDiagnostic &DB, T *DC) {
return DB;
}

// Convert scope enums to their underlying type, so that we don't have
// Convert scoped enums to their underlying type, so that we don't have
// clutter the emitting code with `llvm::to_underlying()`.
// We also need to disable implicit conversion for the first argument,
// because classes that derive from StreamingDiagnostic define their own
// templated operator<< that accept a wide variety of types, leading
// to ambiguity.
template <typename T, typename U>
template <typename T, typename U,
typename UnderlyingU = typename std::enable_if_t<
std::is_enum_v<std::remove_reference_t<U>>,
std::underlying_type<std::remove_reference_t<U>>>::type>
inline std::enable_if_t<
std::is_same_v<std::remove_const_t<T>, StreamingDiagnostic> &&
llvm::is_scoped_enum_v<std::remove_reference_t<U>>,
!std::is_convertible_v<U, UnderlyingU>,
const StreamingDiagnostic &>
operator<<(const T &DB, U &&SE) {
DB << llvm::to_underlying(SE);
Expand Down
5 changes: 0 additions & 5 deletions llvm/include/llvm/ADT/STLForwardCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ struct from_range_t {
explicit from_range_t() = default;
};
inline constexpr from_range_t from_range{};

template <typename T, typename UnderlyingT = std::underlying_type_t<T>>
constexpr bool is_scoped_enum_v =
std::is_enum_v<T> && !std::is_convertible_v<T, UnderlyingT>;

} // namespace llvm

#endif // LLVM_ADT_STLFORWARDCOMPAT_H
Loading