[libc++] Move everything related solely to _LIBCPP_ASSERT to its own file

This is the first step towards disentangling the debug mode and assertions
in libc++. This patch doesn't make any functional change: it simply moves
_LIBCPP_ASSERT-related stuff to its own file so as to make it clear that
libc++ assertions and the debug mode are different things. Future patches
will make it possible to enable assertions without enabling the debug
mode.

Differential Revision: https://reviews.llvm.org/D119769
This commit is contained in:
Louis Dionne 2022-02-14 13:41:09 -05:00
parent ae62aaa171
commit f87aa19be6
74 changed files with 181 additions and 104 deletions

View File

@ -99,6 +99,7 @@ set(files
__algorithm/unique_copy.h
__algorithm/unwrap_iter.h
__algorithm/upper_bound.h
__assert
__availability
__bit/bit_cast.h
__bit/byteswap.h

View File

@ -10,8 +10,8 @@
#define _LIBCPP___ALGORITHM_CLAMP_H
#include <__algorithm/comp.h>
#include <__assert>
#include <__config>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header

View File

@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__utility/declval.h>

View File

@ -10,8 +10,8 @@
#define _LIBCPP___ALGORITHM_SAMPLE_H
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__random/uniform_int_distribution.h>
#include <iterator>

69
libcxx/include/__assert Normal file
View File

@ -0,0 +1,69 @@
// -*- 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___ASSERT
#define _LIBCPP___ASSERT
#include <__config>
#include <iosfwd> // for std::string
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : ::std::__libcpp_debug_function(::std::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#else
# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
#endif
// We do this dance because some of our tests re-define _LIBCPP_ASSERT to something else.
// In the future, we should find other ways to test our assertions and disallow re-defining
// _LIBCPP_ASSERT.
#if !defined(_LIBCPP_ASSERT)
# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info()
: __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
_LIBCPP_FUNC_VIS string what() const;
const char* __file_;
int __line_;
const char* __pred_;
const char* __msg_;
};
/// __libcpp_debug_function_type - The type of the assertion failure handler.
typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
/// fails.
extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function;
/// __libcpp_abort_debug_function - A debug handler that aborts when called.
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
void __libcpp_abort_debug_function(__libcpp_debug_info const&);
/// __libcpp_set_debug_function - Set the debug handler to the specified
/// function.
_LIBCPP_FUNC_VIS
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ASSERT

View File

@ -9,8 +9,8 @@
#ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
#define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/hash.h>
#include <__memory/addressof.h>
#include <compare>

View File

@ -10,6 +10,7 @@
#ifndef _LIBCPP_DEBUG_H
#define _LIBCPP_DEBUG_H
#include <__assert>
#include <__config>
#include <iosfwd>
#include <type_traits>
@ -24,57 +25,16 @@
# include <cstdlib>
#endif
#if _LIBCPP_DEBUG_LEVEL == 0
#if _LIBCPP_DEBUG_LEVEL == 0 || _LIBCPP_DEBUG_LEVEL == 1
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0)
#elif _LIBCPP_DEBUG_LEVEL == 1
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : ::std::__libcpp_debug_function(::std::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#elif _LIBCPP_DEBUG_LEVEL == 2
# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : ::std::__libcpp_debug_function(::std::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#else
# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2
#endif
#if !defined(_LIBCPP_ASSERT)
# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m)
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info()
: __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
_LIBCPP_FUNC_VIS string what() const;
const char* __file_;
int __line_;
const char* __pred_;
const char* __msg_;
};
/// __libcpp_debug_function_type - The type of the assertion failure handler.
typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
/// fails.
extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function;
/// __libcpp_abort_debug_function - A debug handler that aborts when called.
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
void __libcpp_abort_debug_function(__libcpp_debug_info const&);
/// __libcpp_set_debug_function - Set the debug handler to the specified
/// function.
_LIBCPP_FUNC_VIS
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY)
struct _LIBCPP_TYPE_VIS __c_node;

View File

@ -10,9 +10,9 @@
#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__debug>
#include <__filesystem/directory_entry.h>
#include <__filesystem/directory_options.h>
#include <__filesystem/path.h>

View File

@ -10,9 +10,9 @@
#ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
#include <__assert>
#include <__availability>
#include <__config>
#include <__debug>
#include <__filesystem/path.h>
#include <__iterator/iterator_traits.h>
#include <cstddef>

View File

@ -10,6 +10,7 @@
#ifndef _LIBCPP___FORMAT_FORMAT_ARG_H
#define _LIBCPP___FORMAT_FORMAT_ARG_H
#include <__assert>
#include <__concepts/arithmetic.h>
#include <__config>
#include <__format/format_error.h>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___FORMAT_FORMAT_STRING_H
#define _LIBCPP___FORMAT_FORMAT_STRING_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__format/format_error.h>
#include <cstddef>
#include <cstdint>

View File

@ -13,6 +13,7 @@
#include <__algorithm/copy.h>
#include <__algorithm/fill_n.h>
#include <__algorithm/transform.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__format/format_error.h>

View File

@ -17,9 +17,9 @@
#include <__algorithm/min.h>
#include <__algorithm/rotate.h>
#include <__algorithm/transform.h>
#include <__assert>
#include <__concepts/arithmetic.h>
#include <__config>
#include <__debug>
#include <__format/format_error.h>
#include <__format/format_fwd.h>
#include <__format/format_string.h>

View File

@ -14,6 +14,7 @@
#include <__algorithm/copy_n.h>
#include <__algorithm/fill_n.h>
#include <__algorithm/transform.h>
#include <__assert>
#include <__config>
#include <__format/format_error.h>
#include <__format/format_fwd.h>

View File

@ -11,9 +11,9 @@
#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
#include <__algorithm/copy.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__debug>
#include <__format/format_error.h>
#include <__format/format_fwd.h>
#include <__format/formatter.h>

View File

@ -10,6 +10,7 @@
#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H
#define _LIBCPP___FORMAT_FORMATTER_STRING_H
#include <__assert>
#include <__config>
#include <__format/format_error.h>
#include <__format/format_fwd.h>

View File

@ -12,8 +12,8 @@
#include <__algorithm/find_if.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__format/format_arg.h>
#include <__format/format_error.h>
#include <__format/format_string.h>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H
#define _LIBCPP___FUNCTIONAL_FUNCTION_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/binary_function.h>
#include <__functional/invoke.h>
#include <__functional/unary_function.h>

View File

@ -12,6 +12,7 @@
#include <__algorithm/max.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__bits> // __libcpp_clz
#include <__config>
#include <__debug>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_ADVANCE_H
#define _LIBCPP___ITERATOR_ADVANCE_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_COMMON_ITERATOR_H
#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iter_move.h>

View File

@ -9,8 +9,8 @@
#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/default_sentinel.h>
#include <__iterator/incrementable_traits.h>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_NEXT_H
#define _LIBCPP___ITERATOR_NEXT_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___ITERATOR_PREV_H
#define _LIBCPP___ITERATOR_PREV_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H
#define _LIBCPP___MEMORY_CONSTRUCT_AT_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/access.h>
#include <__memory/addressof.h>
#include <__memory/voidify.h>

View File

@ -58,8 +58,8 @@ public:
*/
#include <__assert>
#include <__config>
#include <__debug>
#include <memory>
#include <optional>

View File

@ -10,8 +10,8 @@
#ifndef _LIBCPP___NUMERIC_GCD_LCM_H
#define _LIBCPP___NUMERIC_GCD_LCM_H
#include <__assert>
#include <__config>
#include <__debug>
#include <limits>
#include <type_traits>

View File

@ -9,8 +9,8 @@
#ifndef _LIBCPP___RANGES_DROP_VIEW_H
#define _LIBCPP___RANGES_DROP_VIEW_H
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>

View File

@ -9,6 +9,7 @@
#ifndef _LIBCPP___RANGES_IOTA_VIEW_H
#define _LIBCPP___RANGES_IOTA_VIEW_H
#include <__assert>
#include <__compare/three_way_comparable.h>
#include <__concepts/arithmetic.h>
#include <__concepts/constructible.h>
@ -20,7 +21,6 @@
#include <__concepts/semiregular.h>
#include <__concepts/totally_ordered.h>
#include <__config>
#include <__debug>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>

View File

@ -9,13 +9,13 @@
#ifndef _LIBCPP___RANGES_SUBRANGE_H
#define _LIBCPP___RANGES_SUBRANGE_H
#include <__assert>
#include <__concepts/constructible.h>
#include <__concepts/convertible_to.h>
#include <__concepts/copyable.h>
#include <__concepts/derived_from.h>
#include <__concepts/different_from.h>
#include <__config>
#include <__debug>
#include <__iterator/advance.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>

View File

@ -9,10 +9,10 @@
#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
#define _LIBCPP___RANGES_VIEW_INTERFACE_H
#include <__assert>
#include <__concepts/derived_from.h>
#include <__concepts/same_as.h>
#include <__config>
#include <__debug>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/prev.h>

View File

@ -17,7 +17,9 @@
#include <__algorithm/find_end.h>
#include <__algorithm/find_first_of.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/hash.h> // for __murmur2_or_cityhash
#include <__iterator/iterator_traits.h>
#include <cstdint> // for uint_least16_t
@ -30,8 +32,6 @@
# include <cwchar> // for wmemcpy
#endif
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

View File

@ -112,8 +112,8 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <__algorithm/fill_n.h>
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/swap_ranges.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__tuple>
#include <__utility/unreachable.h>
#include <iterator>

View File

@ -61,11 +61,11 @@ namespace std {
*/
#include <__assert>
#include <__bit/bit_cast.h>
#include <__bit/byteswap.h>
#include <__bits> // __libcpp_clz
#include <__config>
#include <__debug>
#include <limits>
#include <type_traits>
#include <version>

View File

@ -77,6 +77,7 @@ namespace std {
*/
#include <__assert>
#include <__availability>
#include <__bits>
#include <__charconv/chars_format.h>

View File

@ -169,8 +169,8 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/remove.h>
#include <__algorithm/remove_if.h>
#include <__algorithm/unwrap_iter.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/iterator_traits.h>
#include <__split_buffer>
#include <__utility/forward.h>

View File

@ -45,7 +45,7 @@ template <class P> struct hash<coroutine_handle<P>>;
*/
#include <__debug>
#include <__assert>
#include <cstddef>
#include <experimental/__config>
#include <functional>

View File

@ -64,7 +64,7 @@ namespace pmr {
*/
#include <__debug>
#include <__assert>
#include <__tuple>
#include <cstddef>
#include <cstdlib>

View File

@ -180,9 +180,9 @@ typedef basic_fstream<wchar_t> wfstream;
*/
#include <__algorithm/max.h>
#include <__assert>
#include <__availability>
#include <__config>
#include <__debug>
#include <__locale>
#include <__utility/unreachable.h>
#include <cstdio>

View File

@ -361,9 +361,9 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
*/
#include <__assert>
#include <__availability>
#include <__config>
#include <__debug>
#include <__memory/allocator_arg_t.h>
#include <__memory/uses_allocator.h>
#include <__utility/auto_cast.h>

View File

@ -184,6 +184,7 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/equal.h>
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__utility/forward.h>

View File

@ -192,6 +192,7 @@ template <class charT> class messages_byname;
#include <__algorithm/max.h>
#include <__algorithm/reverse.h>
#include <__algorithm/unwrap_iter.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__locale>

View File

@ -530,8 +530,8 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/equal.h>
#include <__algorithm/lexicographical_compare.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/is_transparent.h>
#include <__iterator/iterator_traits.h>
#include <__node_handle>

View File

@ -989,6 +989,7 @@ module std [system] {
// __config not modularised due to a bug in Clang
// FIXME: These should be private.
module __assert { header "__assert" export * }
module __availability { private header "__availability" export * }
module __bit_reference { private header "__bit_reference" export * }
module __bits { private header "__bits" export * }

View File

@ -158,10 +158,10 @@ template<class T>
*/
#include <__assert>
#include <__availability>
#include <__concepts/invocable.h>
#include <__config>
#include <__debug>
#include <compare>
#include <functional>
#include <initializer_list>

View File

@ -763,8 +763,8 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
*/
#include <__algorithm/find.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/wrap_iter.h>
#include <__locale>
#include <compare>

View File

@ -473,8 +473,8 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/equal.h>
#include <__algorithm/lexicographical_compare.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/is_transparent.h>
#include <__iterator/iterator_traits.h>
#include <__node_handle>

View File

@ -127,6 +127,7 @@ template<class R>
*/
#include <__assert>
#include <__config>
#include <__debug>
#include <__iterator/concepts.h>

View File

@ -522,6 +522,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
#include <__algorithm/min.h>
#include <__algorithm/remove.h>
#include <__algorithm/remove_if.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__ios/fpos.h>

View File

@ -196,8 +196,8 @@ namespace std {
*/
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__ranges/concepts.h>
#include <__ranges/data.h>
#include <__ranges/enable_borrowed_range.h>

View File

@ -82,8 +82,8 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
*/
#include <__assert>
#include <__config>
#include <__debug>
#include <__mutex_base>
#include <__thread/poll_with_backoff.h>
#include <__thread/timed_backoff_policy.h>

View File

@ -515,6 +515,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
*/
#include <__algorithm/is_permutation.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/is_transparent.h>

View File

@ -460,6 +460,7 @@ template <class Value, class Hash, class Pred, class Alloc>
*/
#include <__algorithm/is_permutation.h>
#include <__assert>
#include <__config>
#include <__debug>
#include <__functional/is_transparent.h>

View File

@ -279,6 +279,7 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
#include <__algorithm/remove_if.h>
#include <__algorithm/rotate.h>
#include <__algorithm/unwrap_iter.h>
#include <__assert>
#include <__bit_reference>
#include <__config>
#include <__debug>

View File

@ -65,6 +65,7 @@ set(LIBCXX_SOURCES
if (LIBCXX_ENABLE_DEBUG_MODE_SUPPORT)
list(APPEND LIBCXX_SOURCES
assert.cpp
debug.cpp
)
endif()

38
libcxx/src/assert.cpp Normal file
View File

@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__config>
#include <cstdio>
#include <cstdlib>
#include <string>
_LIBCPP_BEGIN_NAMESPACE_STD
std::string __libcpp_debug_info::what() const {
string msg = __file_;
msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '";
msg += __pred_;
msg += "' failed. ";
msg += __msg_;
return msg;
}
_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
std::fprintf(stderr, "%s\n", info.what().c_str());
std::abort();
}
constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
__libcpp_debug_function = __func;
return true;
}
_LIBCPP_END_NAMESPACE_STD

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__config>
#include <__debug>
#include <__hash_table>
@ -23,26 +24,6 @@
_LIBCPP_BEGIN_NAMESPACE_STD
std::string __libcpp_debug_info::what() const {
string msg = __file_;
msg += ":" + to_string(__line_) + ": _LIBCPP_ASSERT '";
msg += __pred_;
msg += "' failed. ";
msg += __msg_;
return msg;
}
_LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) {
std::fprintf(stderr, "%s\n", info.what().c_str());
std::abort();
}
constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function;
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) {
__libcpp_debug_function = __func;
return true;
}
_LIBCPP_FUNC_VIS
__libcpp_db*
__get_db()

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__config>
#include <errno.h>
#include <filesystem>

View File

@ -9,6 +9,7 @@
#ifndef FILESYSTEM_COMMON_H
#define FILESYSTEM_COMMON_H
#include <__assert>
#include <__config>
#include <array>
#include <chrono>

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__utility/unreachable.h>
#include <array>
#include <climits>

View File

@ -23,6 +23,7 @@
#ifndef POSIX_COMPAT_H
#define POSIX_COMPAT_H
#include <__assert>
#include <filesystem>
#include "filesystem_common.h"

View File

@ -42,6 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
#include <__assert>
#include "__config"
_LIBCPP_BEGIN_NAMESPACE_STD

View File

@ -42,6 +42,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
#include <__assert>
#include <__config>
#include "include/ryu/ryu.h"

View File

@ -21,6 +21,7 @@
#include <__algorithm/find_if.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__iterator/access.h>
#include <__iterator/size.h>

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <limits>
#include <mutex>
#include <system_error>

View File

@ -39,6 +39,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
#include <__assert>
#include <__config>
#include <charconv>
#include <cstring>

View File

@ -39,6 +39,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
#include <__assert>
#include <__config>
#include <charconv>

View File

@ -39,6 +39,7 @@
// Avoid formatting to keep the changes with the original code minimal.
// clang-format off
#include <__assert>
#include <__config>
#include <charconv>

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include <__debug>
#include <__assert>
#include <cerrno>
#include <charconv>
#include <cstdlib>

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__utility/unreachable.h>
#include <__debug>
#include <algorithm>
#include <climits>
#include <cstdlib>

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__support/ibm/xlocale.h>
#include <sstream>
#include <vector>

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#include <__assert>
#include <__config>
#include <__debug>
#include <cerrno>
#include <cstdio>
#include <cstdlib>

View File

@ -11,9 +11,9 @@
// Test that the default debug handler aborts the program.
#include <__assert>
#include <csignal>
#include <cstdlib>
#include <__debug>
#include "test_macros.h"

View File

@ -52,7 +52,7 @@ def relative_path(path):
def is_still_public(path):
rp = relative_path(path)
return not rp.startswith('__support') and rp not in [
"__bsd_locale_defaults.h", "__bsd_locale_fallbacks.h", "__config",
"__assert", "__bsd_locale_defaults.h", "__bsd_locale_fallbacks.h", "__config",
"__config_site.in", "__debug", "__hash_table",
"__libcpp_version", "__threading_support", "__tree", "__undef_macros"
]