blob: 40c51f872bcd92e54d949fa63017d25cfd7ae250 [file] [log] [blame]
Louis Dionne9bdbeb32022-02-14 13:41:09 -05001//===----------------------------------------------------------------------===//
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#include <__assert>
10#include <__config>
11#include <cstdio>
12#include <cstdlib>
13#include <string>
14
15_LIBCPP_BEGIN_NAMESPACE_STD
16
17std::string __libcpp_debug_info::what() const {
18 string msg = __file_;
19 msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '";
20 msg += __pred_;
21 msg += "' failed. ";
22 msg += __msg_;
23 return msg;
24}
25
26_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
27 std::fprintf(stderr, "%s\n", info.what().c_str());
28 std::abort();
29}
30
31constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;
32
33bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
34 __libcpp_debug_function = __func;
35 return true;
36}
37
38_LIBCPP_END_NAMESPACE_STD