[libcxx-commits] [PATCH] D119152: [libc++] Implement P0627R6 (Function to mark unreachable code)

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 7 09:24:13 PST 2022


philnik created this revision.
philnik added reviewers: ldionne, Quuxplusone, Mordante, var-const.
Herald added a subscriber: mgorny.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119152

Files:
  libcxx/docs/Status/Cxx2bPapers.csv
  libcxx/include/CMakeLists.txt
  libcxx/include/__utility/unreachable.h
  libcxx/include/module.modulemap
  libcxx/include/utility


Index: libcxx/include/utility
===================================================================
--- libcxx/include/utility
+++ 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 <compare>
 #include <initializer_list>
 #include <version>
Index: libcxx/include/module.modulemap
===================================================================
--- libcxx/include/module.modulemap
+++ 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 {
Index: libcxx/include/__utility/unreachable.h
===================================================================
--- /dev/null
+++ 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
Index: libcxx/include/CMakeLists.txt
===================================================================
--- libcxx/include/CMakeLists.txt
+++ 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
Index: libcxx/docs/Status/Cxx2bPapers.csv
===================================================================
--- libcxx/docs/Status/Cxx2bPapers.csv
+++ libcxx/docs/Status/Cxx2bPapers.csv
@@ -38,3 +38,5 @@
 "`P2393R1 <https://wg21.link/P2393R1>`__","LWG","Cleaning up ``integer``-class types","October 2021","",""
 "`P2401R0 <https://wg21.link/P2401R0>`__","LWG","Add a conditional ``noexcept`` specification to ``std::exchange``","October 2021","|Complete|","14.0"
 "","","","","",""
+"`P0627R6 <https://wg21.link/P0627R6>`__","LWG","Function to mark unreachable code","February 2022","|Complete|"","15.0"
+"","","","","",""


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119152.406499.patch
Type: text/x-patch
Size: 2786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220207/6c4bed3b/attachment.bin>


More information about the libcxx-commits mailing list