aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxxmsvc/src/assert.cpp
blob: 21a3863cd051a08deb01d6c298d6627aefbbef28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <__assert>
#include <__config>
#include <cstdio>
#include <cstdlib>
#include <string>

_LIBCPP_BEGIN_NAMESPACE_STD

std::string __libcpp_debug_info::what() const {
  string msg = __file_;
  msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '";
  msg += __pred_;
  msg += "' failed. ";
  msg += __msg_;
  return msg;
}

_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
    std::fprintf(stderr, "%s\n", info.what().c_str());
    std::abort();
}

_LIBCPP_CONSTINIT __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;

bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
  __libcpp_debug_function = __func;
  return true;
}

_LIBCPP_END_NAMESPACE_STD