[all-commits] [llvm/llvm-project] 678dd9: [libc++] Improve the implementation of std::unreac...

Louis Dionne via All-commits all-commits at lists.llvm.org
Wed Jan 11 07:15:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 678dd9a589d62159c76886d22fa9ccbd1222e1f2
      https://github.com/llvm/llvm-project/commit/678dd9a589d62159c76886d22fa9ccbd1222e1f2
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2023-01-11 (Wed, 11 Jan 2023)

  Changed paths:
    M libcxx/include/__utility/unreachable.h
    M libcxx/include/utility
    M libcxx/test/libcxx/transitive_includes/cxx2b.csv
    A libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp
    R libcxx/test/std/utilities/utility/utility.unreachable/unreachable.compile.pass.cpp
    A libcxx/test/std/utilities/utility/utility.unreachable/unreachable.pass.cpp

  Log Message:
  -----------
  [libc++] Improve the implementation of std::unreachable

First, use __builtin_unreachable unconditionally. It is implemented by
all the compilers that we support. Clang started supporting it around
Clang 4, and GCC around GCC 4.10.

Also add _LIBCPP_ASSERT so that we will actually get a guaranteed crash
if we reached `std::unreachable()` and assertions have been enabled,
since that's UB that's extremely easy to catch.

Differential Revision: https://reviews.llvm.org/D131620




More information about the All-commits mailing list