[libc++] Introduce the _LIBCPP_VERBOSE_TRAP macro (#148262)
Split out the calls to __builtin_verbose_trap into a separate header. This is just a refactoring to make the code a bit more structured.
This commit is contained in:
parent
e35b01da11
commit
5951c44573
5 changed files with 80 additions and 12 deletions
|
|
@ -944,6 +944,7 @@ set(files
|
|||
__vector/vector_bool.h
|
||||
__vector/vector_bool_formatter.h
|
||||
__verbose_abort
|
||||
__verbose_trap
|
||||
algorithm
|
||||
any
|
||||
array
|
||||
|
|
@ -1569,6 +1570,7 @@ set(files
|
|||
__cxx03/__utility/unreachable.h
|
||||
__cxx03/__variant/monostate.h
|
||||
__cxx03/__verbose_abort
|
||||
__cxx03/__verbose_trap
|
||||
__cxx03/algorithm
|
||||
__cxx03/array
|
||||
__cxx03/atomic
|
||||
|
|
|
|||
36
libcxx/include/__cxx03/__verbose_trap
Normal file
36
libcxx/include/__cxx03/__verbose_trap
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___CXX03___VERBOSE_TRAP
|
||||
#define _LIBCPP___CXX03___VERBOSE_TRAP
|
||||
|
||||
#include <__cxx03/__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if __has_builtin(__builtin_verbose_trap)
|
||||
// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
|
||||
// version before upstream Clang actually got the builtin.
|
||||
// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
|
||||
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
|
||||
# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap(message)
|
||||
# else
|
||||
# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap("libc++", message)
|
||||
# endif
|
||||
#else
|
||||
# define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___CXX03___VERBOSE_TRAP
|
||||
36
libcxx/include/__verbose_trap
Normal file
36
libcxx/include/__verbose_trap
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___VERBOSE_TRAP
|
||||
#define _LIBCPP___VERBOSE_TRAP
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if __has_builtin(__builtin_verbose_trap)
|
||||
// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
|
||||
// version before upstream Clang actually got the builtin.
|
||||
// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
|
||||
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
|
||||
# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap(message)
|
||||
# else
|
||||
# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap("libc++", message)
|
||||
# endif
|
||||
#else
|
||||
# define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___VERBOSE_TRAP
|
||||
|
|
@ -2356,6 +2356,9 @@ module std [system] {
|
|||
module verbose_abort {
|
||||
header "__verbose_abort"
|
||||
}
|
||||
module verbose_trap {
|
||||
header "__verbose_trap"
|
||||
}
|
||||
module internal_assert {
|
||||
header "__assert"
|
||||
export *
|
||||
|
|
|
|||
15
libcxx/vendor/llvm/default_assertion_handler.in
vendored
15
libcxx/vendor/llvm/default_assertion_handler.in
vendored
|
|
@ -13,9 +13,11 @@
|
|||
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
|
||||
# include <__cxx03/__config>
|
||||
# include <__cxx03/__verbose_abort>
|
||||
# include <__cxx03/__verbose_trap>
|
||||
#else
|
||||
# include <__config>
|
||||
# include <__verbose_abort>
|
||||
# include <__verbose_trap>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
|
|
@ -28,18 +30,7 @@
|
|||
|
||||
#else
|
||||
|
||||
# if __has_builtin(__builtin_verbose_trap)
|
||||
// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
|
||||
// version before upstream Clang actually got the builtin.
|
||||
// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
|
||||
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
|
||||
# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
|
||||
# else
|
||||
# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
|
||||
# endif
|
||||
# else
|
||||
# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
|
||||
# endif
|
||||
# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message)
|
||||
|
||||
#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue