brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · f8b6967 Raw
53 lines · plain
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___VERBOSE_ABORT11#define _LIBCPP___VERBOSE_ABORT12 13#include <__config>14 15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#  pragma GCC system_header17#endif18 19_LIBCPP_BEGIN_NAMESPACE_STD20 21// This function should never be called directly from the code -- it should only be called through22// the _LIBCPP_VERBOSE_ABORT macro.23[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(24    __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;25 26// _LIBCPP_VERBOSE_ABORT(format, args...)27//28// This macro is used to abort the program abnormally while providing additional diagnostic information.29//30// The first argument is a printf-style format string, and the remaining arguments are values to format31// into the format-string. This macro can be customized by users to provide fine-grained control over32// how verbose termination is triggered.33//34// If the user does not supply their own version of the _LIBCPP_VERBOSE_ABORT macro, we pick the default35// behavior based on whether we know the built library we're running against provides support for the36// verbose termination handler or not. If it does, we call it. If it doesn't, we call __builtin_abort to37// make sure that the program terminates but without taking any complex dependencies in this header.38#if !defined(_LIBCPP_VERBOSE_ABORT)39 40#  if !_LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT41// The decltype is there to suppress -Wunused warnings in this configuration.42void __use(const char*, ...);43#    define _LIBCPP_VERBOSE_ABORT(...) (decltype(::std::__use(__VA_ARGS__))(), __builtin_abort())44#  else45#    define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)46#  endif47 48#endif // !defined(_LIBCPP_VERBOSE_ABORT)49 50_LIBCPP_END_NAMESPACE_STD51 52#endif // _LIBCPP___VERBOSE_ABORT53