https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/138134

>From 31a9c444b5ef6155ec1cdb35d9e659dd60b21dcc Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com>
Date: Thu, 1 May 2025 16:51:38 +0300
Subject: [PATCH 1/2] [ADT] Make `is_scoped_enum_v` SFINAE-able

...in old compilers where `std::underlying_type` is not SFINAE-friendly. Fixes 
buildbot failure https://lab.llvm.org/buildbot/#/builders/134/builds/17904 
caused by #138089
---
 llvm/include/llvm/ADT/STLForwardCompat.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/STLForwardCompat.h 
b/llvm/include/llvm/ADT/STLForwardCompat.h
index b8d4babc95fea..c70f4dc29aee0 100644
--- a/llvm/include/llvm/ADT/STLForwardCompat.h
+++ b/llvm/include/llvm/ADT/STLForwardCompat.h
@@ -73,7 +73,8 @@ struct from_range_t {
 };
 inline constexpr from_range_t from_range{};
 
-template <typename T, typename UnderlyingT = std::underlying_type_t<T>>
+template <typename T, typename UnderlyingT = typename std::enable_if_t<
+                          std::is_enum_v<T>, std::underlying_type<T>>::type>
 constexpr bool is_scoped_enum_v =
     std::is_enum_v<T> && !std::is_convertible_v<T, UnderlyingT>;
 

>From e3b74e1d49b00b11a304b73d0ccaf8b5e926e79f Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com>
Date: Thu, 1 May 2025 17:21:15 +0300
Subject: [PATCH 2/2] Attempt 2: inline implementation in the only place it's
 used

---
 clang/include/clang/Basic/Diagnostic.h   | 9 ++++++---
 llvm/include/llvm/ADT/STLForwardCompat.h | 6 ------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 92ab61b95a7c6..0ba4edcc5d54c 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -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);
diff --git a/llvm/include/llvm/ADT/STLForwardCompat.h 
b/llvm/include/llvm/ADT/STLForwardCompat.h
index c70f4dc29aee0..75a0d4acf67f1 100644
--- a/llvm/include/llvm/ADT/STLForwardCompat.h
+++ b/llvm/include/llvm/ADT/STLForwardCompat.h
@@ -72,12 +72,6 @@ struct from_range_t {
   explicit from_range_t() = default;
 };
 inline constexpr from_range_t from_range{};
-
-template <typename T, typename UnderlyingT = typename std::enable_if_t<
-                          std::is_enum_v<T>, std::underlying_type<T>>::type>
-constexpr bool is_scoped_enum_v =
-    std::is_enum_v<T> && !std::is_convertible_v<T, UnderlyingT>;
-
 } // namespace llvm
 
 #endif // LLVM_ADT_STLFORWARDCOMPAT_H

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to