14df029ccSDimitry Andric// -*- C++ -*- 24df029ccSDimitry Andric//===----------------------------------------------------------------------===// 34df029ccSDimitry Andric// 44df029ccSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 54df029ccSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 64df029ccSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 74df029ccSDimitry Andric// 84df029ccSDimitry Andric//===----------------------------------------------------------------------===// 94df029ccSDimitry Andric 104df029ccSDimitry Andric#ifndef _LIBCPP___ASSERTION_HANDLER 114df029ccSDimitry Andric#define _LIBCPP___ASSERTION_HANDLER 124df029ccSDimitry Andric 134df029ccSDimitry Andric#include <__config> 144df029ccSDimitry Andric#include <__verbose_abort> 154df029ccSDimitry Andric 164df029ccSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 174df029ccSDimitry Andric# pragma GCC system_header 184df029ccSDimitry Andric#endif 194df029ccSDimitry Andric 204df029ccSDimitry Andric#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 214df029ccSDimitry Andric 224df029ccSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) 234df029ccSDimitry Andric 244df029ccSDimitry Andric#else 254df029ccSDimitry Andric 26ac9a064cSDimitry Andric# if __has_builtin(__builtin_verbose_trap) 27ac9a064cSDimitry Andric// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream 28ac9a064cSDimitry Andric// version before upstream Clang actually got the builtin. 2903706295SDimitry Andric// TODO: Remove once AppleClang supports the two-arguments version of the builtin. 3003706295SDimitry Andric# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700 31ac9a064cSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message) 32ac9a064cSDimitry Andric# else 33ac9a064cSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message) 34ac9a064cSDimitry Andric# endif 35ac9a064cSDimitry Andric# else 364df029ccSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) 37ac9a064cSDimitry Andric# endif 384df029ccSDimitry Andric 394df029ccSDimitry Andric#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 404df029ccSDimitry Andric 414df029ccSDimitry Andric#endif // _LIBCPP___ASSERTION_HANDLER 42