diff --git a/libcxx/docs/Status/Cxx2bPapers.csv b/libcxx/docs/Status/Cxx2bPapers.csv --- a/libcxx/docs/Status/Cxx2bPapers.csv +++ b/libcxx/docs/Status/Cxx2bPapers.csv @@ -38,3 +38,5 @@ "`P2393R1 `__","LWG","Cleaning up ``integer``-class types","October 2021","","" "`P2401R0 `__","LWG","Add a conditional ``noexcept`` specification to ``std::exchange``","October 2021","|Complete|","14.0" "","","","","","" +"`P0627R6 `__","LWG","Function to mark unreachable code","February 2022","|Complete|"","15.0" +"","","","","","" diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -397,6 +397,7 @@ __utility/swap.h __utility/to_underlying.h __utility/transaction.h + __utility/unreachable.h __variant/monostate.h algorithm any diff --git a/libcxx/include/__utility/unreachable.h b/libcxx/include/__utility/unreachable.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__utility/unreachable.h @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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___UTILITY_UNREACHABLE_H +#define _LIBCPP___UTILITY_UNREACHABLE_H + +#include <__config> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 20 + +[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __builtin_unreachable(); } + +#endif // _LIBCPP_STD_VER > 20 + +_LIBCPP_END_NAMESPACE_STD + +#endif diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -953,6 +953,7 @@ module swap { private header "__utility/swap.h" } module to_underlying { private header "__utility/to_underlying.h" } module transaction { private header "__utility/transaction.h" } + module unreachable { private header "__utility/unreachable.h" } } } module valarray { diff --git a/libcxx/include/utility b/libcxx/include/utility --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -239,6 +239,7 @@ #include <__utility/swap.h> #include <__utility/to_underlying.h> #include <__utility/transaction.h> +#include <__utility/unreachable.h> #include #include #include