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___ASSERT 11#define _LIBCPP___ASSERT 12 13#include <__availability> 14#include <__config> 15 16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17# pragma GCC system_header 18#endif 19 20// This is for backwards compatibility with code that might have been enabling 21// assertions through the Debug mode previously. 22#if _LIBCPP_DEBUG_LEVEL >= 1 23# ifndef _LIBCPP_ENABLE_ASSERTIONS 24# define _LIBCPP_ENABLE_ASSERTIONS 1 25# endif 26#endif 27 28#ifndef _LIBCPP_ENABLE_ASSERTIONS 29# define _LIBCPP_ENABLE_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS_DEFAULT 30#endif 31 32#if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 33# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" 34#endif 35 36#if _LIBCPP_ENABLE_ASSERTIONS 37# define _LIBCPP_ASSERT(expression, message) ((expression) ? (void)0 : ::std::__libcpp_assertion_handler(__FILE__, __LINE__, #expression, message)) 38#else 39# define _LIBCPP_ASSERT(x, m) ((void)0) 40#endif 41 42_LIBCPP_BEGIN_NAMESPACE_STD 43 44_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ASSERTION_HANDLER 45void __libcpp_assertion_handler(char const* __file, int __line, char const* __expression, char const* __message); 46 47_LIBCPP_END_NAMESPACE_STD 48 49#endif // _LIBCPP___ASSERT 50