[libcxx-commits] [PATCH] D131620: [libc++] Use __builtin_unreachable unconditionally
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 10 14:27:52 PDT 2022
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
It is implemented by all the compilers that we support. Clang started
supporting it around Clang 4, and GCC around GCC 4.10 if I recall
correctly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131620
Files:
libcxx/include/__utility/unreachable.h
Index: libcxx/include/__utility/unreachable.h
===================================================================
--- libcxx/include/__utility/unreachable.h
+++ libcxx/include/__utility/unreachable.h
@@ -10,7 +10,6 @@
#define _LIBCPP___UTILITY_UNREACHABLE_H
#include <__config>
-#include <cstdlib>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,21 +17,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable()
-{
-#if __has_builtin(__builtin_unreachable)
- __builtin_unreachable();
-#else
- std::abort();
-#endif
-}
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() { __builtin_unreachable(); }
#if _LIBCPP_STD_VER > 20
[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
-#endif // _LIBCPP_STD_VER > 20
+#endif
_LIBCPP_END_NAMESPACE_STD
-#endif
+#endif // _LIBCPP___UTILITY_UNREACHABLE_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131620.451631.patch
Type: text/x-patch
Size: 968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220810/9d44590a/attachment.bin>
More information about the libcxx-commits
mailing list