|  | 
|  | 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___LOG_HARDENING_FAILURE | 
|  | 11 | +#define _LIBCPP___LOG_HARDENING_FAILURE | 
|  | 12 | + | 
|  | 13 | +#include <__config> | 
|  | 14 | + | 
|  | 15 | +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
|  | 16 | +#  pragma GCC system_header | 
|  | 17 | +#endif | 
|  | 18 | + | 
|  | 19 | +_LIBCPP_BEGIN_NAMESPACE_STD | 
|  | 20 | + | 
|  | 21 | +// This function should never be called directly from the code -- it should only be called through the | 
|  | 22 | +// `_LIBCPP_LOG_HARDENING_FAILURE` macro. | 
|  | 23 | +_LIBCPP_AVAILABILITY_LOG_HARDENING_FAILURE _LIBCPP_OVERRIDABLE_FUNC_VIS void | 
|  | 24 | +__libcpp_log_hardening_failure(const char* message) _NOEXCEPT; | 
|  | 25 | + | 
|  | 26 | +// _LIBCPP_LOG_HARDENING_FAILURE(message) | 
|  | 27 | +// | 
|  | 28 | +// This macro is used to log a hardening failure without terminating the program (as is the case if the `observe` | 
|  | 29 | +// assertion semantic is used). Where possible, it logs in a way that indicates a fatal error (which might include | 
|  | 30 | +// capturing the stack trace). | 
|  | 31 | +#if !defined(_LIBCPP_LOG_HARDENING_FAILURE) | 
|  | 32 | + | 
|  | 33 | +#  if !_LIBCPP_AVAILABILITY_HAS_LOG_HARDENING_FAILURE | 
|  | 34 | +// The decltype is there to suppress -Wunused warnings in this configuration. | 
|  | 35 | +void __use(const char*); | 
|  | 36 | +#    define _LIBCPP_LOG_HARDENING_FAILURE(message) (decltype(::std::__use(message))()) | 
|  | 37 | +#  else | 
|  | 38 | +#    define _LIBCPP_LOG_HARDENING_FAILURE(message) ::std::__libcpp_log_hardening_failure(message) | 
|  | 39 | +#  endif | 
|  | 40 | + | 
|  | 41 | +#endif // !defined(_LIBCPP_LOG_HARDENING_FAILURE) | 
|  | 42 | + | 
|  | 43 | +_LIBCPP_END_NAMESPACE_STD | 
|  | 44 | + | 
|  | 45 | +#endif // _LIBCPP___LOG_HARDENING_FAILURE | 
0 commit comments