Louis Dionne | 9bdbeb3 | 2022-02-14 13:41:09 -0500 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 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 | |
| 17 | std::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 | |
| 31 | constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function; |
| 32 | |
| 33 | bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) { |
| 34 | __libcpp_debug_function = __func; |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | _LIBCPP_END_NAMESPACE_STD |