[libcxx-commits] [libcxx] [libc++] Add a utility for checking the output of commands (PR #65917)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 2 08:47:14 PST 2025
================
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// This test is checking the LLVM IR
+// REQUIRES: clang
+
+// RUN: %{cxx} %s %{compile_flags} -O3 -c -S -emit-llvm -o - | %{check-output}
+
+#include <utility>
+
+[[noreturn]] void test() {
+ // CHECK: define dso_local void
+ // CHECK-SAME: test
+ // CHECK-NEXT: unreachable
+ // CHECK-NEXT: }
+ std::unreachable();
----------------
philnik777 wrote:
We're making sure that we actually tell the compiler that calling `std::unreachable()` is UB. `unreachable() {}` would also be a valid implementation, just a low QoI one. I don't think there is any other way to test that.
https://github.com/llvm/llvm-project/pull/65917
More information about the libcxx-commits
mailing list