 |
Bitcoin Core
23.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #ifndef BITCOIN_UTIL_CHECK_H
6 #define BITCOIN_UTIL_CHECK_H
8 #if defined(HAVE_CONFIG_H)
18 using std::runtime_error::runtime_error;
21 #define format_internal_error(msg, file, line, func, report) \
22 strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", \
23 msg, file, line, func, report)
33 return std::forward<T>(val);
47 #define CHECK_NONFATAL(condition) \
48 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
51 #error "Cannot compile without assertions!"
55 void assertion_fail(
const char* file,
int line,
const char* func,
const char* assertion);
58 template <
bool IS_ASSERT,
typename T>
59 T&&
inline_assertion_check(T&& val, [[maybe_unused]]
const char* file, [[maybe_unused]]
int line, [[maybe_unused]]
const char* func, [[maybe_unused]]
const char* assertion)
61 if constexpr (IS_ASSERT
62 #ifdef ABORT_ON_FAILED_ASSUME
70 return std::forward<T>(val);
74 #define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
86 #define Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val)
92 #define NONFATAL_UNREACHABLE() \
93 throw NonFatalCheckError( \
94 format_internal_error("Unreachable code reached (non-fatal)", \
95 __FILE__, __LINE__, __func__, PACKAGE_BUGREPORT))
97 #endif // BITCOIN_UTIL_CHECK_H
T && inline_check_non_fatal(T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
#define PACKAGE_BUGREPORT
void assertion_fail(const char *file, int line, const char *func, const char *assertion)
Helper for Assert()
#define format_internal_error(msg, file, line, func, report)
T && inline_assertion_check(T &&val, [[maybe_unused]] const char *file, [[maybe_unused]] int line, [[maybe_unused]] const char *func, [[maybe_unused]] const char *assertion)
Helper for Assert()/Assume()
#define T(expected, seed, data)