Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef _LIBCPP___UTILITY_UNREACHABLE_H |
| 10 | #define _LIBCPP___UTILITY_UNREACHABLE_H |
| 11 | |
Louis Dionne | 678dd9a | 2022-08-10 21:27:00 | [diff] [blame] | 12 | #include <__assert> |
Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 13 | #include <__config> |
Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 14 | |
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header |
Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 17 | #endif |
| 18 | |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | |
Nikolas Klauser | 748023dc | 2024-09-11 06:59:46 | [diff] [blame^] | 21 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() { |
Konstantin Varlamov | 4f215fd | 2024-01-06 00:29:23 | [diff] [blame] | 22 | _LIBCPP_ASSERT_INTERNAL(false, "std::unreachable() was reached"); |
Louis Dionne | 9783f28 | 2023-12-18 19:01:33 | [diff] [blame] | 23 | __builtin_unreachable(); |
Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 24 | } |
| 25 | |
Nikolas Klauser | 4f15267 | 2023-02-13 23:56:09 | [diff] [blame] | 26 | #if _LIBCPP_STD_VER >= 23 |
Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 27 | |
| 28 | [[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); } |
| 29 | |
Louis Dionne | 678dd9a | 2022-08-10 21:27:00 | [diff] [blame] | 30 | #endif |
Nikolas Klauser | 2a8f9a5 | 2022-02-14 17:26:02 | [diff] [blame] | 31 | |
| 32 | _LIBCPP_END_NAMESPACE_STD |
| 33 | |
Louis Dionne | 678dd9a | 2022-08-10 21:27:00 | [diff] [blame] | 34 | #endif // _LIBCPP___UTILITY_UNREACHABLE_H |