Skip to content

Conversation

@philnik777
Copy link
Contributor

@philnik777 philnik777 commented Jun 17, 2024

This changes the behaviour in C++03 mode because we'll now use the builtin on Clang, but I don't think that's much of a problem.

@philnik777 philnik777 requested a review from a team as a code owner June 17, 2024 10:50
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jun 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 17, 2024

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

This changes the behaviour in C++03 mode, but I don't think that's much of a problem.


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

1 Files Affected:

  • (modified) libcxx/include/__type_traits/is_nothrow_destructible.h (+7-18)
diff --git a/libcxx/include/__type_traits/is_nothrow_destructible.h b/libcxx/include/__type_traits/is_nothrow_destructible.h
index 370ba27ecd1f1..c2d5ca87232aa 100644
--- a/libcxx/include/__type_traits/is_nothrow_destructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_destructible.h
@@ -12,9 +12,6 @@
 #include <__config>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_destructible.h>
-#include <__type_traits/is_reference.h>
-#include <__type_traits/is_scalar.h>
-#include <__type_traits/remove_all_extents.h>
 #include <__utility/declval.h>
 #include <cstddef>
 
@@ -24,7 +21,12 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if !defined(_LIBCPP_CXX03_LANG)
+#if __has_builtin(__is_nothrow_destructible)
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {};
+
+#else
 
 template <bool, class _Tp>
 struct __libcpp_is_nothrow_destructible;
@@ -49,20 +51,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {};
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {};
 
-#else
-
-template <class _Tp>
-struct __libcpp_nothrow_destructor : public integral_constant<bool, is_scalar<_Tp>::value || is_reference<_Tp>::value> {
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : public __libcpp_nothrow_destructor<__remove_all_extents_t<_Tp> > {
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> : public false_type {};
-
-#endif
+#endif // __has_builtin(__is_nothrow_destructible)
 
 #if _LIBCPP_STD_VER >= 17
 template <class _Tp>

@philnik777 philnik777 force-pushed the use_is_nothrow_destructible_builtin branch from 79e92b0 to 46bbf9c Compare June 20, 2024 09:31
Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with small change.

@philnik777 philnik777 force-pushed the use_is_nothrow_destructible_builtin branch from 46bbf9c to 177b29b Compare June 23, 2024 21:12
@philnik777 philnik777 merged commit 16d02cd into llvm:main Jun 25, 2024
@philnik777 philnik777 deleted the use_is_nothrow_destructible_builtin branch June 25, 2024 09:20
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
This changes the behaviour in C++03 mode because we'll now use the
builtin on Clang, but I don't think that's much of a problem.
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.

3 participants