5 #ifndef BITCOIN_UTIL_CHECK_H
6 #define BITCOIN_UTIL_CHECK_H
8 #if defined(HAVE_CONFIG_H)
9 #include <config/bitcoin-config.h>
17 using std::runtime_error::runtime_error;
20 #define format_internal_error(msg, file, line, func, report) \
21 strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this " \
23 msg, file, line, func, report)
28 const char *func,
const char *assertion) {
31 assertion, file, line, func, PACKAGE_BUGREPORT));
34 return std::forward<T>(val);
52 #define CHECK_NONFATAL(condition) \
53 inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
56 #error "Cannot compile without assertions!"
61 return std::forward<T>(val);
66 ([&]() -> decltype(get_pure_r_value(val)) { \
67 auto &&check = (val); \
68 assert(#val &&check); \
69 return std::forward<decltype(get_pure_r_value(val))>(check); \
82 #ifdef ABORT_ON_FAILED_ASSUME
83 #define Assume(val) Assert(val)
86 ([&]() -> decltype(get_pure_r_value(val)) { \
87 auto &&check = (val); \
88 return std::forward<decltype(get_pure_r_value(val))>(check); \
98 #define NONFATAL_UNREACHABLE() \
99 throw NonFatalCheckError(format_internal_error( \
100 "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__, \
T get_pure_r_value(T &&val)
Helper for Assert()
#define format_internal_error(msg, file, line, func, report)
T && inline_check_non_fatal(T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()