Skip to content

Conversation

philnik777
Copy link
Contributor

@philnik777 philnik777 commented Apr 28, 2025

We can use the __is_nothrow_convertible builtin unconditionally now, which makes the implementation very simple, so there isn't much of a need to keep a separate header around.

@philnik777 philnik777 marked this pull request as ready for review April 29, 2025 06:46
@philnik777 philnik777 requested a review from a team as a code owner April 29, 2025 06:46
@philnik777 philnik777 merged commit e43e8ec into llvm:main Apr 29, 2025
87 checks passed
@philnik777 philnik777 deleted the simplify_is_nothrow_convertible branch April 29, 2025 06:46
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 29, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

We can use the __is_nothrow_convertible builtin unconditionally now, which makes the implementation very simple, so there isn't much of a need to keep a separate header around.


Full diff: https://github.com/llvm/llvm-project/pull/137717.diff

5 Files Affected:

  • (modified) libcxx/include/CMakeLists.txt (-1)
  • (modified) libcxx/include/__type_traits/is_convertible.h (+10)
  • (removed) libcxx/include/__type_traits/is_nothrow_convertible.h (-62)
  • (modified) libcxx/include/module.modulemap.in (-4)
  • (modified) libcxx/include/type_traits (-1)
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index f1bdf684a8549..0277382cc84dd 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -835,7 +835,6 @@ set(files
   __type_traits/is_member_pointer.h
   __type_traits/is_nothrow_assignable.h
   __type_traits/is_nothrow_constructible.h
-  __type_traits/is_nothrow_convertible.h
   __type_traits/is_nothrow_destructible.h
   __type_traits/is_null_pointer.h
   __type_traits/is_object.h
diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h
index cef3c4a764914..f0a859f9cc16d 100644
--- a/libcxx/include/__type_traits/is_convertible.h
+++ b/libcxx/include/__type_traits/is_convertible.h
@@ -26,6 +26,16 @@ template <class _From, class _To>
 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
 #endif
 
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp, class _Up>
+struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
+
+template <class _Tp, class _Up>
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
+
+#endif // _LIBCPP_STD_VER >= 20
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
diff --git a/libcxx/include/__type_traits/is_nothrow_convertible.h b/libcxx/include/__type_traits/is_nothrow_convertible.h
deleted file mode 100644
index f114619296437..0000000000000
--- a/libcxx/include/__type_traits/is_nothrow_convertible.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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 _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
-#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
-
-#include <__config>
-#include <__type_traits/conjunction.h>
-#include <__type_traits/disjunction.h>
-#include <__type_traits/integral_constant.h>
-#include <__type_traits/is_convertible.h>
-#include <__type_traits/is_void.h>
-#include <__type_traits/lazy.h>
-#include <__utility/declval.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-#if _LIBCPP_STD_VER >= 20
-
-#  if __has_builtin(__is_nothrow_convertible)
-
-template <class _Tp, class _Up>
-struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
-
-template <class _Tp, class _Up>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
-
-#  else // __has_builtin(__is_nothrow_convertible)
-
-template <typename _Tp>
-void __test_noexcept(_Tp) noexcept;
-
-template <typename _Fm, typename _To>
-bool_constant<noexcept(std::__test_noexcept<_To>(std::declval<_Fm>()))> __is_nothrow_convertible_test();
-
-template <typename _Fm, typename _To>
-struct __is_nothrow_convertible_helper : decltype(std::__is_nothrow_convertible_test<_Fm, _To>()) {};
-
-template <typename _Fm, typename _To>
-struct is_nothrow_convertible
-    : _Or<_And<is_void<_To>, is_void<_Fm>>,
-          _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To> > >::type {};
-
-template <typename _Fm, typename _To>
-inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
-
-#  endif // __has_builtin(__is_nothrow_convertible)
-
-#endif // _LIBCPP_STD_VER >= 20
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index af928a63f2315..7260c3a5d51f3 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -232,10 +232,6 @@ module std_core [system] {
       header "__type_traits/is_nothrow_constructible.h"
       export std_core.type_traits.integral_constant
     }
-    module is_nothrow_convertible {
-      header "__type_traits/is_nothrow_convertible.h"
-      export std_core.type_traits.integral_constant
-    }
     module is_nothrow_destructible {
       header "__type_traits/is_nothrow_destructible.h"
       export std_core.type_traits.integral_constant
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index b63f61cfefe8e..9db7b2afb0cf3 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -549,7 +549,6 @@ namespace std
 #    include <__type_traits/common_reference.h>
 #    include <__type_traits/is_bounded_array.h>
 #    include <__type_traits/is_constant_evaluated.h>
-#    include <__type_traits/is_nothrow_convertible.h>
 #    include <__type_traits/is_unbounded_array.h>
 #    include <__type_traits/type_identity.h>
 #    include <__type_traits/unwrap_ref.h>

aarongable pushed a commit to chromium/chromium that referenced this pull request Apr 30, 2025
This patch removes the is_nothrow_convertible.h file from the list of
available headers, to match the changes in
llvm/llvm-project#137717

Bug: 40263312
Change-Id: I02fcaef097d83c0674c6c3b573b2e199e4f76305
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6500519
Commit-Queue: Takuto Ikuta <[email protected]>
Commit-Queue: Hans Wennborg <[email protected]>
Reviewed-by: Hans Wennborg <[email protected]>
Auto-Submit: Takuto Ikuta <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1453797}
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…ge the remaining code into is_convertible.h (llvm#137717)

We can use the `__is_nothrow_convertible` builtin unconditionally now,
which makes the implementation very simple, so there isn't much of a
need to keep a separate header around.
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
…ge the remaining code into is_convertible.h (llvm#137717)

We can use the `__is_nothrow_convertible` builtin unconditionally now,
which makes the implementation very simple, so there isn't much of a
need to keep a separate header around.
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Jun 27, 2025
… and merge the remaining code into is_convertible.h (llvm#137717)"

This reverts commit e43e8ec.
gailium119 pushed a commit to gailium119/buildtools that referenced this pull request Jul 5, 2025
This patch removes the is_nothrow_convertible.h file from the list of
available headers, to match the changes in
llvm/llvm-project#137717

Bug: 40263312
Change-Id: I02fcaef097d83c0674c6c3b573b2e199e4f76305
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6500519
Commit-Queue: Takuto Ikuta <[email protected]>
Commit-Queue: Hans Wennborg <[email protected]>
Reviewed-by: Hans Wennborg <[email protected]>
Auto-Submit: Takuto Ikuta <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1453797}
NOKEYCHECK=True
GitOrigin-RevId: eb78f6c171696cdcb36aeff50d64b081166d57d4
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Jul 18, 2025
… and merge the remaining code into is_convertible.h (llvm#137717)"

This reverts commit e43e8ec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants