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 13770cf0a5SDimitry Andric#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 14770cf0a5SDimitry Andric# include <__cxx03/__config> 15770cf0a5SDimitry Andric# include <__cxx03/__verbose_abort> 16770cf0a5SDimitry Andric# include <__cxx03/__verbose_trap> 17770cf0a5SDimitry Andric#else 187a6dacacSDimitry Andric# include <__config> 19*e64bea71SDimitry Andric# include <__log_hardening_failure> 207a6dacacSDimitry Andric# include <__verbose_abort> 21770cf0a5SDimitry Andric# include <__verbose_trap> 22770cf0a5SDimitry Andric#endif 237a6dacacSDimitry Andric 247a6dacacSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 257a6dacacSDimitry Andric# pragma GCC system_header 267a6dacacSDimitry Andric#endif 277a6dacacSDimitry Andric 28*e64bea71SDimitry Andric#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 297a6dacacSDimitry Andric 30*e64bea71SDimitry Andric// Keep the old implementation that doesn't support assertion semantics for backward compatibility with the frozen C++03 31*e64bea71SDimitry Andric// mode. 32*e64bea71SDimitry Andric# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 33*e64bea71SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) 34*e64bea71SDimitry Andric# else 35*e64bea71SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) 36*e64bea71SDimitry Andric# endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 37*e64bea71SDimitry Andric 38*e64bea71SDimitry Andric#else 39*e64bea71SDimitry Andric 40*e64bea71SDimitry Andric# if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_IGNORE 41*e64bea71SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) ((void)0) 42*e64bea71SDimitry Andric 43*e64bea71SDimitry Andric# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE 44*e64bea71SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_LOG_HARDENING_FAILURE(message) 45*e64bea71SDimitry Andric 46*e64bea71SDimitry Andric# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE 47*e64bea71SDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) 48*e64bea71SDimitry Andric 49*e64bea71SDimitry Andric# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE 507a6dacacSDimitry Andric# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) 517a6dacacSDimitry Andric 527a6dacacSDimitry Andric# else 537a6dacacSDimitry Andric 54*e64bea71SDimitry Andric# error _LIBCPP_ASSERTION_SEMANTIC must be set to one of the following values: \ 55*e64bea71SDimitry Andric_LIBCPP_ASSERTION_SEMANTIC_IGNORE, \ 56*e64bea71SDimitry Andric_LIBCPP_ASSERTION_SEMANTIC_OBSERVE, \ 57*e64bea71SDimitry Andric_LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE, \ 58*e64bea71SDimitry Andric_LIBCPP_ASSERTION_SEMANTIC_ENFORCE 597a6dacacSDimitry Andric 60*e64bea71SDimitry Andric# endif // _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_IGNORE 61*e64bea71SDimitry Andric 62*e64bea71SDimitry Andric#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 637a6dacacSDimitry Andric 647a6dacacSDimitry Andric#endif // _LIBCPP___ASSERTION_HANDLER 65