5#ifndef BITCOIN_UTIL_CHECK_H
6#define BITCOIN_UTIL_CHECK_H
17#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
39 return std::forward<T>(val);
43#error "Cannot compile without assertions!"
47void assertion_fail(std::string_view file,
int line, std::string_view func, std::string_view assertion);
50template <
bool IS_ASSERT,
typename T>
51constexpr T&&
inline_assertion_check(
LIFETIMEBOUND T&& val, [[maybe_unused]]
const char* file, [[maybe_unused]]
int line, [[maybe_unused]]
const char* func, [[maybe_unused]]
const char* assertion)
53 if (IS_ASSERT || std::is_constant_evaluated() ||
G_FUZZING
54#ifdef ABORT_ON_FAILED_ASSUME
62 return std::forward<T>(val);
68#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
81#define CHECK_NONFATAL(condition) \
82 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
85#define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
97#define Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val)
102#define NONFATAL_UNREACHABLE() \
103 throw NonFatalCheckError( \
104 "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__)
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
constexpr T && inline_assertion_check(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for Assert()/Assume()
std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
Helper for Assert()
NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
#define T(expected, seed, data)