1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP___ASSERTION_HANDLER 11#define _LIBCPP___ASSERTION_HANDLER 12 13#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 14# include <__cxx03/__config> 15# include <__cxx03/__verbose_abort> 16# include <__cxx03/__verbose_trap> 17#else 18# include <__config> 19# include <__log_hardening_failure> 20# include <__verbose_abort> 21# include <__verbose_trap> 22#endif 23 24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 25# pragma GCC system_header 26#endif 27 28#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 29 30// Keep the old implementation that doesn't support assertion semantics for backward compatibility with the frozen C++03 31// mode. 32# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 33# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) 34# else 35# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) 36# endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG 37 38#else 39 40# if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_IGNORE 41# define _LIBCPP_ASSERTION_HANDLER(message) ((void)0) 42 43# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE 44# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_LOG_HARDENING_FAILURE(message) 45 46# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE 47# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) 48 49# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE 50# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) 51 52# else 53 54# error _LIBCPP_ASSERTION_SEMANTIC must be set to one of the following values: \ 55_LIBCPP_ASSERTION_SEMANTIC_IGNORE, \ 56_LIBCPP_ASSERTION_SEMANTIC_OBSERVE, \ 57_LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE, \ 58_LIBCPP_ASSERTION_SEMANTIC_ENFORCE 59 60# endif // _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_IGNORE 61 62#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 63 64#endif // _LIBCPP___ASSERTION_HANDLER 65