17a6dacacSDimitry Andric// -*- C++ -*- 27a6dacacSDimitry Andric//===----------------------------------------------------------------------===// 37a6dacacSDimitry Andric// 47a6dacacSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 57a6dacacSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 67a6dacacSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 77a6dacacSDimitry Andric// 87a6dacacSDimitry Andric//===----------------------------------------------------------------------===// 97a6dacacSDimitry Andric 107a6dacacSDimitry Andric#ifndef _LIBCPP___ASSERTION_HANDLER 117a6dacacSDimitry Andric#define _LIBCPP___ASSERTION_HANDLER 127a6dacacSDimitry Andric 137a6dacacSDimitry Andric#include <__config> 147a6dacacSDimitry Andric#include <__verbose_abort> 157a6dacacSDimitry Andric 167a6dacacSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 177a6dacacSDimitry Andric# pragma GCC system_header 187a6dacacSDimitry Andric#endif 197a6dacacSDimitry Andric 207a6dacacSDimitry Andric#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 217a6dacacSDimitry Andric 227a6dacacSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) 237a6dacacSDimitry Andric 247a6dacacSDimitry Andric#else 257a6dacacSDimitry Andric 260fca6ea1SDimitry Andric# if __has_builtin(__builtin_verbose_trap) 270fca6ea1SDimitry Andric// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream 280fca6ea1SDimitry Andric// version before upstream Clang actually got the builtin. 29*d686ce93SDimitry Andric// TODO: Remove once AppleClang supports the two-arguments version of the builtin. 30*d686ce93SDimitry Andric# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700 310fca6ea1SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message) 320fca6ea1SDimitry Andric# else 330fca6ea1SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message) 340fca6ea1SDimitry Andric# endif 350fca6ea1SDimitry Andric# else 367a6dacacSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) 370fca6ea1SDimitry Andric# endif 387a6dacacSDimitry Andric 397a6dacacSDimitry Andric#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 407a6dacacSDimitry Andric 417a6dacacSDimitry Andric#endif // _LIBCPP___ASSERTION_HANDLER 42