xref: /llvm-project/libcxx/vendor/llvm/default_assertion_handler.in (revision b9a2658a3e8bd13b0f9e7a8a440832a95b377216)
18dfc67d6SKonstantin Varlamov// -*- C++ -*-
28dfc67d6SKonstantin Varlamov//===----------------------------------------------------------------------===//
38dfc67d6SKonstantin Varlamov//
48dfc67d6SKonstantin Varlamov// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
58dfc67d6SKonstantin Varlamov// See https://llvm.org/LICENSE.txt for license information.
68dfc67d6SKonstantin Varlamov// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
78dfc67d6SKonstantin Varlamov//
88dfc67d6SKonstantin Varlamov//===----------------------------------------------------------------------===//
98dfc67d6SKonstantin Varlamov
108dfc67d6SKonstantin Varlamov#ifndef _LIBCPP___ASSERTION_HANDLER
118dfc67d6SKonstantin Varlamov#define _LIBCPP___ASSERTION_HANDLER
128dfc67d6SKonstantin Varlamov
13*b9a2658aSNikolas Klauser#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
14*b9a2658aSNikolas Klauser#  include <__cxx03/__config>
15*b9a2658aSNikolas Klauser#  include <__cxx03/__verbose_abort>
16*b9a2658aSNikolas Klauser#else
178dfc67d6SKonstantin Varlamov#  include <__config>
188dfc67d6SKonstantin Varlamov#  include <__verbose_abort>
19*b9a2658aSNikolas Klauser#endif
208dfc67d6SKonstantin Varlamov
218dfc67d6SKonstantin Varlamov#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
228dfc67d6SKonstantin Varlamov#  pragma GCC system_header
238dfc67d6SKonstantin Varlamov#endif
248dfc67d6SKonstantin Varlamov
2558780b81SKonstantin Varlamov#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
2658780b81SKonstantin Varlamov
278dfc67d6SKonstantin Varlamov#  define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)
288dfc67d6SKonstantin Varlamov
2958780b81SKonstantin Varlamov#else
3058780b81SKonstantin Varlamov
311e96b4adSKonstantin Varlamov#  if __has_builtin(__builtin_verbose_trap)
32ffda5212SLouis Dionne// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
33ffda5212SLouis Dionne// version before upstream Clang actually got the builtin.
341b60c38eSLouis Dionne// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
351eba8790SLouis Dionne#    if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
36ffda5212SLouis Dionne#      define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
37ffda5212SLouis Dionne#    else
381e96b4adSKonstantin Varlamov#      define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
39ffda5212SLouis Dionne#    endif
401e96b4adSKonstantin Varlamov#  else
4158780b81SKonstantin Varlamov#    define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
421e96b4adSKonstantin Varlamov#  endif
4358780b81SKonstantin Varlamov
4458780b81SKonstantin Varlamov#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
4558780b81SKonstantin Varlamov
468dfc67d6SKonstantin Varlamov#endif // _LIBCPP___ASSERTION_HANDLER
47