[libc-commits] [libc] [libc] Fix shared math for gcc-7 or older compatibility. (PR #197476)

via libc-commits libc-commits at lists.llvm.org
Wed May 13 11:51:45 PDT 2026


https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/197476

>From 78fba21fd04914421d330b57379333844615ab9a Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 13 May 2026 15:25:34 +0000
Subject: [PATCH 1/3] [libc] Fix shared math for gcc-7 or older compatibility.

---
 .../__support/CPP/type_traits/is_assignable.h | 59 ++++++++++++++++++
 .../CPP/type_traits/is_constructible.h        | 61 +++++++++++++++++++
 .../CPP/type_traits/is_copy_assignable.h      |  7 +--
 .../CPP/type_traits/is_copy_constructible.h   |  5 +-
 .../CPP/type_traits/is_move_assignable.h      |  7 +--
 .../CPP/type_traits/is_move_constructible.h   |  5 +-
 libc/src/__support/FPUtil/rounding_mode.h     | 10 +--
 libc/src/__support/macros/attributes.h        | 12 ++++
 libc/src/__support/macros/config.h            |  2 +
 9 files changed, 149 insertions(+), 19 deletions(-)
 create mode 100644 libc/src/__support/CPP/type_traits/is_assignable.h
 create mode 100644 libc/src/__support/CPP/type_traits/is_constructible.h

diff --git a/libc/src/__support/CPP/type_traits/is_assignable.h b/libc/src/__support/CPP/type_traits/is_assignable.h
new file mode 100644
index 0000000000000..88b450ced00bd
--- /dev/null
+++ b/libc/src/__support/CPP/type_traits/is_assignable.h
@@ -0,0 +1,59 @@
+//===-- is_assignable type_traits -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ASSIGNABLE_H
+#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ASSIGNABLE_H
+
+#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
+#include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace cpp {
+
+namespace is_assignable_detail {
+
+#if LIBC_HAS_BUITLIN_IS_ASSIGNABLE
+
+template <typename T, typename U>
+struct is_assignable_impl : public bool_constant<__is_assignable(T, U)> {};
+
+#else
+// Fallback SFINAE implementation for GCC 7 and older toolchains
+
+// Reuse declval from is_constructible or declare locally
+template <typename T> typename add_rvalue_reference<T>::type declval() noexcept;
+
+template <typename T, typename U> struct is_assignable_impl {
+private:
+  template <typename T1, typename U1>
+  static auto test(int)
+      -> decltype(declval<T1>() = declval<U1>(), bool_constant<true>());
+
+  template <typename, typename> static auto test(...) -> bool_constant<false>;
+
+public:
+  using type = decltype(test<T, U>(0));
+};
+
+#endif // LIBC_HAS_BUITLIN_IS_ASSIGNABLE
+
+} // namespace is_assignable_detail
+
+// is_assignable
+template <typename T, typename U>
+struct is_assignable
+    : public is_assignable_detail::is_assignable_impl<T, U>::type {};
+
+template <typename T, typename U>
+LIBC_INLINE_VAR constexpr bool is_assignable_v = is_assignable<T, U>::value;
+
+} // namespace cpp
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ASSIGNABLE_H
diff --git a/libc/src/__support/CPP/type_traits/is_constructible.h b/libc/src/__support/CPP/type_traits/is_constructible.h
new file mode 100644
index 0000000000000..45796657c0299
--- /dev/null
+++ b/libc/src/__support/CPP/type_traits/is_constructible.h
@@ -0,0 +1,61 @@
+//===-- is_constructible type_traits ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTRUCTIBLE_H
+#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTRUCTIBLE_H
+
+#include "src/__support/CPP/type_traits/add_lvalue_reference.h"
+#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
+#include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace cpp {
+
+namespace is_contructible_detail {
+
+#if LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+
+template <typename T, typename... Args>
+struct is_constructible_impl
+    : public bool_constant<__is_constructible(T, Args...)> {};
+
+#else
+// Fallback SFINAE implementation for GCC 7 and older toolchains
+
+template <typename T> typename add_rvalue_reference_t<T>::type declval();
+
+template <typename T, typename... Args> struct is_constructible_impl {
+private:
+  template <typename T1, typename... Args1>
+  LIBC_INLINE static auto test(int)
+      -> decltype(T1(declval<Args1>()...), bool_constant<true>());
+
+  template <typename, typename...>
+  LIBC_INLINE static auto test(...) -> bool_constant<false>;
+
+public:
+  using type = decltype(test<T, Args...>(0));
+};
+
+#endif // LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+
+} // namespace is_contructible_detail
+
+template <typename T, typename... Args>
+struct is_constructible
+    : public is_contructible_detail::is_constructible_impl<T, Args...>::type {};
+
+template <typename T, typename... Args>
+LIBC_INLINE_VAR constexpr bool is_constructible_v =
+    is_constructible<T, Args...>::value;
+
+} // namespace cpp
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTRUCTIBLE_H
diff --git a/libc/src/__support/CPP/type_traits/is_copy_assignable.h b/libc/src/__support/CPP/type_traits/is_copy_assignable.h
index 9beb93d14668d..97c30c668a4e3 100644
--- a/libc/src/__support/CPP/type_traits/is_copy_assignable.h
+++ b/libc/src/__support/CPP/type_traits/is_copy_assignable.h
@@ -9,7 +9,7 @@
 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
 
 #include "src/__support/CPP/type_traits/add_lvalue_reference.h"
-#include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/CPP/type_traits/is_assignable.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
@@ -18,9 +18,8 @@ namespace cpp {
 // is copy assignable
 template <class T>
 struct is_copy_assignable
-    : public integral_constant<
-          bool, __is_assignable(cpp::add_lvalue_reference_t<T>,
-                                cpp::add_lvalue_reference_t<const T>)> {};
+    : public cpp::is_assignable<cpp::add_lvalue_reference_t<T>,
+                                cpp::add_lvalue_reference_t<const T>> {};
 
 template <class T>
 LIBC_INLINE_VAR constexpr bool is_copy_assignable_v =
diff --git a/libc/src/__support/CPP/type_traits/is_copy_constructible.h b/libc/src/__support/CPP/type_traits/is_copy_constructible.h
index d8eb9ad3507ee..c62db8f69b680 100644
--- a/libc/src/__support/CPP/type_traits/is_copy_constructible.h
+++ b/libc/src/__support/CPP/type_traits/is_copy_constructible.h
@@ -9,7 +9,7 @@
 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
 
 #include "src/__support/CPP/type_traits/add_lvalue_reference.h"
-#include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/CPP/type_traits/is_constructible.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
@@ -18,8 +18,7 @@ namespace cpp {
 // is copy constructible
 template <class T>
 struct is_copy_constructible
-    : public integral_constant<
-          bool, __is_constructible(T, cpp::add_lvalue_reference_t<const T>)> {};
+    : public cpp::is_constructible<T, cpp::add_lvalue_reference_t<const T>> {};
 
 template <class T>
 LIBC_INLINE_VAR constexpr bool is_copy_constructible_v =
diff --git a/libc/src/__support/CPP/type_traits/is_move_assignable.h b/libc/src/__support/CPP/type_traits/is_move_assignable.h
index a788bd9074e32..edffe094c58a3 100644
--- a/libc/src/__support/CPP/type_traits/is_move_assignable.h
+++ b/libc/src/__support/CPP/type_traits/is_move_assignable.h
@@ -10,7 +10,7 @@
 
 #include "src/__support/CPP/type_traits/add_lvalue_reference.h"
 #include "src/__support/CPP/type_traits/add_rvalue_reference.h"
-#include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/CPP/type_traits/is_assignable.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
@@ -19,9 +19,8 @@ namespace cpp {
 // is move assignable
 template <class T>
 struct is_move_assignable
-    : public integral_constant<bool, __is_assignable(
-                                         cpp::add_lvalue_reference_t<T>,
-                                         cpp::add_rvalue_reference_t<T>)> {};
+    : public cpp::is_assignable<cpp::add_lvalue_reference_t<T>,
+                                cpp::add_rvalue_reference_t<T>> {};
 
 template <class T>
 LIBC_INLINE_VAR constexpr bool is_move_assignable_v =
diff --git a/libc/src/__support/CPP/type_traits/is_move_constructible.h b/libc/src/__support/CPP/type_traits/is_move_constructible.h
index c898960546258..37d540c27a5f6 100644
--- a/libc/src/__support/CPP/type_traits/is_move_constructible.h
+++ b/libc/src/__support/CPP/type_traits/is_move_constructible.h
@@ -9,7 +9,7 @@
 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
 
 #include "src/__support/CPP/type_traits/add_rvalue_reference.h"
-#include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/CPP/type_traits/is_constructible.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
@@ -18,8 +18,7 @@ namespace cpp {
 // is move constructible
 template <class T>
 struct is_move_constructible
-    : public integral_constant<bool, __is_constructible(
-                                         T, cpp::add_rvalue_reference_t<T>)> {};
+    : public cpp::is_constructible<T, cpp::add_rvalue_reference_t<T>> {};
 
 template <class T>
 LIBC_INLINE_VAR constexpr bool is_move_constructible_v =
diff --git a/libc/src/__support/FPUtil/rounding_mode.h b/libc/src/__support/FPUtil/rounding_mode.h
index 92061ea13e203..ebeb3652f64aa 100644
--- a/libc/src/__support/FPUtil/rounding_mode.h
+++ b/libc/src/__support/FPUtil/rounding_mode.h
@@ -80,7 +80,7 @@ LIBC_INLINE int quick_get_round() {
 
 } // namespace generic
 
-LIBC_INLINE constexpr bool fenv_is_round_up() {
+LIBC_INLINE LIBC_CONSTEXPR bool fenv_is_round_up() {
   if (cpp::is_constant_evaluated()) {
     return false;
   } else {
@@ -88,7 +88,7 @@ LIBC_INLINE constexpr bool fenv_is_round_up() {
   }
 }
 
-LIBC_INLINE constexpr bool fenv_is_round_down() {
+LIBC_INLINE LIBC_CONSTEXPR bool fenv_is_round_down() {
   if (cpp::is_constant_evaluated()) {
     return false;
   } else {
@@ -96,7 +96,7 @@ LIBC_INLINE constexpr bool fenv_is_round_down() {
   }
 }
 
-LIBC_INLINE constexpr bool fenv_is_round_to_nearest() {
+LIBC_INLINE LIBC_CONSTEXPR bool fenv_is_round_to_nearest() {
   if (cpp::is_constant_evaluated()) {
     return true;
   } else {
@@ -104,7 +104,7 @@ LIBC_INLINE constexpr bool fenv_is_round_to_nearest() {
   }
 }
 
-LIBC_INLINE constexpr bool fenv_is_round_to_zero() {
+LIBC_INLINE LIBC_CONSTEXPR bool fenv_is_round_to_zero() {
   if (cpp::is_constant_evaluated()) {
     return false;
   } else {
@@ -113,7 +113,7 @@ LIBC_INLINE constexpr bool fenv_is_round_to_zero() {
 }
 
 // Quick free standing get rounding mode based on the above observations.
-LIBC_INLINE constexpr int quick_get_round() {
+LIBC_INLINE LIBC_CONSTEXPR int quick_get_round() {
   if (cpp::is_constant_evaluated()) {
     return FE_TONEAREST;
   } else {
diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index 7ec708b75e897..b7be6ede08efb 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -58,6 +58,18 @@
 #define LIBC_CONSTEXPR
 #endif
 
+#ifndef LIBC_HAS_BUITLIN_IS_ASSIGNABLE
+#define LIBC_HAS_BUILTIN_IS_ASSIGNABLE                                         \
+  (__has_builtin(__is_assignable) ||                                           \
+   (defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 800)))
+#endif // LIBC_HAS_BUITLIN_IS_ASSIGNABLE
+
+#ifndef LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+#define LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE                                      \
+  (__has_builtin(__is_constructible) ||                                        \
+   (defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 800)))
+#endif // LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+
 // Uses the platform specific specialization
 #define LIBC_THREAD_MODE_PLATFORM 0
 
diff --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h
index d9c80423f499d..38ad605473844 100644
--- a/libc/src/__support/macros/config.h
+++ b/libc/src/__support/macros/config.h
@@ -49,6 +49,8 @@
 #define __builtin_prefetch(X, Y, Z)
 
 #define LIBC_HAS_BUILTIN_IS_CONSTANT_EVALUATED 1
+#define LIBC_HAS_BUILTIN_IS_ASSIGNABLE 1
+#define LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE 1
 
 #endif // LIBC_COMPILER_IS_MSVC
 

>From aa6e6b76d7791a9f3feaf3b626c7c51407cfcd53 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 13 May 2026 16:59:38 +0000
Subject: [PATCH 2/3] Fix macro definitions and address comments.

---
 libc/src/__support/CPP/CMakeLists.txt         |  2 ++
 .../__support/CPP/type_traits/is_assignable.h | 25 +++++++++--------
 .../CPP/type_traits/is_constructible.h        | 19 +++++++------
 libc/src/__support/macros/attributes.h        | 28 +++++++++++--------
 4 files changed, 44 insertions(+), 30 deletions(-)

diff --git a/libc/src/__support/CPP/CMakeLists.txt b/libc/src/__support/CPP/CMakeLists.txt
index 03e21ac6c80ca..b602aa1f79d08 100644
--- a/libc/src/__support/CPP/CMakeLists.txt
+++ b/libc/src/__support/CPP/CMakeLists.txt
@@ -130,11 +130,13 @@ add_header_library(
     type_traits/invoke.h
     type_traits/is_arithmetic.h
     type_traits/is_array.h
+    type_traits/is_assignable.h
     type_traits/is_base_of.h
     type_traits/is_class.h
     type_traits/is_complex.h
     type_traits/is_const.h
     type_traits/is_constant_evaluated.h
+    type_traits/is_constructible.h
     type_traits/is_convertible.h
     type_traits/is_destructible.h
     type_traits/is_enum.h
diff --git a/libc/src/__support/CPP/type_traits/is_assignable.h b/libc/src/__support/CPP/type_traits/is_assignable.h
index 88b450ced00bd..18e1696d0b525 100644
--- a/libc/src/__support/CPP/type_traits/is_assignable.h
+++ b/libc/src/__support/CPP/type_traits/is_assignable.h
@@ -1,15 +1,21 @@
-//===-- is_assignable type_traits -------------------------------*- C++ -*-===//
+//===------------------------------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+//
+// This file contains a free-standing implementation of is_assignable
+// type trait.
+//
+//===----------------------------------------------------------------------===//
+
 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ASSIGNABLE_H
 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ASSIGNABLE_H
 
-#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
 #include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/CPP/utility/declval.h"
 #include "src/__support/macros/attributes.h"
 #include "src/__support/macros/config.h"
 
@@ -18,7 +24,7 @@ namespace cpp {
 
 namespace is_assignable_detail {
 
-#if LIBC_HAS_BUITLIN_IS_ASSIGNABLE
+#if LIBC_HAS_BUILTIN_IS_ASSIGNABLE
 
 template <typename T, typename U>
 struct is_assignable_impl : public bool_constant<__is_assignable(T, U)> {};
@@ -26,29 +32,26 @@ struct is_assignable_impl : public bool_constant<__is_assignable(T, U)> {};
 #else
 // Fallback SFINAE implementation for GCC 7 and older toolchains
 
-// Reuse declval from is_constructible or declare locally
-template <typename T> typename add_rvalue_reference<T>::type declval() noexcept;
-
 template <typename T, typename U> struct is_assignable_impl {
 private:
   template <typename T1, typename U1>
-  static auto test(int)
+  LIBC_INLINE static auto test(int)
       -> decltype(declval<T1>() = declval<U1>(), bool_constant<true>());
 
-  template <typename, typename> static auto test(...) -> bool_constant<false>;
+  template <typename, typename>
+  LIBC_INLINE static auto test(...) -> bool_constant<false>;
 
 public:
   using type = decltype(test<T, U>(0));
 };
 
-#endif // LIBC_HAS_BUITLIN_IS_ASSIGNABLE
+#endif // LIBC_HAS_BUILTIN_IS_ASSIGNABLE
 
 } // namespace is_assignable_detail
 
 // is_assignable
 template <typename T, typename U>
-struct is_assignable
-    : public is_assignable_detail::is_assignable_impl<T, U>::type {};
+struct is_assignable : public is_assignable_detail::is_assignable_impl<T, U> {};
 
 template <typename T, typename U>
 LIBC_INLINE_VAR constexpr bool is_assignable_v = is_assignable<T, U>::value;
diff --git a/libc/src/__support/CPP/type_traits/is_constructible.h b/libc/src/__support/CPP/type_traits/is_constructible.h
index 45796657c0299..89e16719fe080 100644
--- a/libc/src/__support/CPP/type_traits/is_constructible.h
+++ b/libc/src/__support/CPP/type_traits/is_constructible.h
@@ -1,16 +1,21 @@
-//===-- is_constructible type_traits ----------------------------*- C++ -*-===//
+//===------------------------------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+//
+// This file contains a free-standing implementation of is_constructible
+// type trait.
+//
+//===----------------------------------------------------------------------===//
+
 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTRUCTIBLE_H
 #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTRUCTIBLE_H
 
-#include "src/__support/CPP/type_traits/add_lvalue_reference.h"
-#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
 #include "src/__support/CPP/type_traits/integral_constant.h"
+#include "src/__support/CPP/utility/declval.h"
 #include "src/__support/macros/attributes.h"
 #include "src/__support/macros/config.h"
 
@@ -19,7 +24,7 @@ namespace cpp {
 
 namespace is_contructible_detail {
 
-#if LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+#if LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE
 
 template <typename T, typename... Args>
 struct is_constructible_impl
@@ -28,8 +33,6 @@ struct is_constructible_impl
 #else
 // Fallback SFINAE implementation for GCC 7 and older toolchains
 
-template <typename T> typename add_rvalue_reference_t<T>::type declval();
-
 template <typename T, typename... Args> struct is_constructible_impl {
 private:
   template <typename T1, typename... Args1>
@@ -43,13 +46,13 @@ template <typename T, typename... Args> struct is_constructible_impl {
   using type = decltype(test<T, Args...>(0));
 };
 
-#endif // LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+#endif // LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE
 
 } // namespace is_contructible_detail
 
 template <typename T, typename... Args>
 struct is_constructible
-    : public is_contructible_detail::is_constructible_impl<T, Args...>::type {};
+    : public is_contructible_detail::is_constructible_impl<T, Args...> {};
 
 template <typename T, typename... Args>
 LIBC_INLINE_VAR constexpr bool is_constructible_v =
diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index b7be6ede08efb..1cd3a309d3cf9 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -58,17 +58,23 @@
 #define LIBC_CONSTEXPR
 #endif
 
-#ifndef LIBC_HAS_BUITLIN_IS_ASSIGNABLE
-#define LIBC_HAS_BUILTIN_IS_ASSIGNABLE                                         \
-  (__has_builtin(__is_assignable) ||                                           \
-   (defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 800)))
-#endif // LIBC_HAS_BUITLIN_IS_ASSIGNABLE
-
-#ifndef LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
-#define LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE                                      \
-  (__has_builtin(__is_constructible) ||                                        \
-   (defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 800)))
-#endif // LIBC_HAS_BUITLIN_IS_CONSTRUCTIBLE
+#ifndef LIBC_HAS_BUILTIN_IS_ASSIGNABLE
+#if (__has_builtin(__is_assignable) ||                                         \
+     (defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 800)))
+#define LIBC_HAS_BUILTIN_IS_ASSIGNABLE 1
+#else
+#define LIBC_HAS_BUILTIN_IS_ASSIGNABLE 0
+#endif
+#endif // LIBC_HAS_BUILTIN_IS_ASSIGNABLE
+
+#ifndef LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE
+#if (__has_builtin(__is_constructible) ||                                      \
+     (defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 800)))
+#define LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE 1
+#else
+#define LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE 0
+#endif
+#endif // LIBC_HAS_BUILTIN_IS_CONSTRUCTIBLE
 
 // Uses the platform specific specialization
 #define LIBC_THREAD_MODE_PLATFORM 0

>From 4151601fada471bf8c473c33f39335ba03466131 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Wed, 13 May 2026 18:51:28 +0000
Subject: [PATCH 3/3] Add \file.

---
 libc/src/__support/CPP/type_traits/is_assignable.h    | 1 +
 libc/src/__support/CPP/type_traits/is_constructible.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libc/src/__support/CPP/type_traits/is_assignable.h b/libc/src/__support/CPP/type_traits/is_assignable.h
index 18e1696d0b525..0be3aa500590d 100644
--- a/libc/src/__support/CPP/type_traits/is_assignable.h
+++ b/libc/src/__support/CPP/type_traits/is_assignable.h
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
+// \file
 // This file contains a free-standing implementation of is_assignable
 // type trait.
 //
diff --git a/libc/src/__support/CPP/type_traits/is_constructible.h b/libc/src/__support/CPP/type_traits/is_constructible.h
index 89e16719fe080..316ba1acba33e 100644
--- a/libc/src/__support/CPP/type_traits/is_constructible.h
+++ b/libc/src/__support/CPP/type_traits/is_constructible.h
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
+// \file
 // This file contains a free-standing implementation of is_constructible
 // type trait.
 //



More information about the libc-commits mailing list