blob: 5525452aa55efd0d8eca8c26b22d2d7d40bfd3df [file] [log] [blame]
Nikolas Klauser2a8f9a52022-02-14 17:26:021//===----------------------------------------------------------------------===//
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 Dionne678dd9a2022-08-10 21:27:0012#include <__assert>
Nikolas Klauser2a8f9a52022-02-14 17:26:0213#include <__config>
Nikolas Klauser2a8f9a52022-02-14 17:26:0214
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
Nikolas Klauser2a8f9a52022-02-14 17:26:0217#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
Nikolas Klauser748023dc2024-09-11 06:59:4621[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() {
Konstantin Varlamov4f215fd2024-01-06 00:29:2322 _LIBCPP_ASSERT_INTERNAL(false, "std::unreachable() was reached");
Louis Dionne9783f282023-12-18 19:01:3323 __builtin_unreachable();
Nikolas Klauser2a8f9a52022-02-14 17:26:0224}
25
Nikolas Klauser4f152672023-02-13 23:56:0926#if _LIBCPP_STD_VER >= 23
Nikolas Klauser2a8f9a52022-02-14 17:26:0227
28[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
29
Louis Dionne678dd9a2022-08-10 21:27:0030#endif
Nikolas Klauser2a8f9a52022-02-14 17:26:0231
32_LIBCPP_END_NAMESPACE_STD
33
Louis Dionne678dd9a2022-08-10 21:27:0034#endif // _LIBCPP___UTILITY_UNREACHABLE_H