5#ifndef BITCOIN_UTIL_CHECK_H
6#define BITCOIN_UTIL_CHECK_H
14#include <source_location>
22#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
29#ifdef ABORT_ON_FAILED_ASSUME
81 return std::forward<T>(val);
85#error "Cannot compile without assertions!"
89template <
bool IS_ASSERT,
typename T>
97 return std::forward<T>(val);
100#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), std::source_location::current())
115#define CHECK_NONFATAL(condition) \
116 inline_check_non_fatal(condition, std::source_location::current(), #condition)
119#define Assert(val) inline_assertion_check<true>(val, std::source_location::current(), #val)
131#define Assume(val) inline_assertion_check<false>(val, std::source_location::current(), #val)
139#define NONFATAL_UNREACHABLE() \
140 internal_non_fatal_helper(std::source_location::current(), "unreachable")
142#if defined(__has_feature)
143# if __has_feature(address_sanitizer)
144# include <sanitizer/asan_interface.h>
148#ifndef ASAN_POISON_MEMORY_REGION
149# define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
150# define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
std::string StrFormatFailedCheck(std::string_view assertion)
void internal_abort_helper(const std::source_location &loc, std::string_view error_msg)
Internal helper. The noreturn enables optimizers to discard invalid paths.
bool g_detail_test_only_CheckFailuresAreExceptionsNotAborts
constexpr T && inline_assertion_check(LIFETIMEBOUND T &&val, const std::source_location &loc, std::string_view assertion)
Helper for Assert()/Assume()
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const std::source_location &loc, std::string_view assertion)
Helper for CHECK_NONFATAL()
void internal_non_fatal_helper(const std::source_location &loc, std::string_view error_msg)
Internal helper. The noreturn enables optimizers to discard invalid paths.
std::atomic< bool > g_enable_dynamic_fuzz_determinism
std::string StrFormatInternalBug(std::string_view msg, const std::source_location &loc)
bool EnableFuzzDeterminism()
constexpr bool G_ABORT_ON_FAILED_ASSUME
constexpr bool G_FUZZING_BUILD
#define T(expected, seed, data)
test_only_CheckFailuresAreExceptionsNotAborts()
~test_only_CheckFailuresAreExceptionsNotAborts()
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.