5 #ifndef BITCOIN_UTIL_CHECK_H 6 #define BITCOIN_UTIL_CHECK_H 13 #include <string_view> 17 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 39 return std::forward<T>(val);
43 #error "Cannot compile without assertions!" 47 void assertion_fail(std::string_view file,
int line, std::string_view func, std::string_view assertion);
50 template <
bool IS_ASSERT,
typename T>
51 constexpr
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__) 108 #endif // BITCOIN_UTIL_CHECK_H
T && inline_check_non_fatal(LIFETIMEBOUND T &&val, const char *file, int line, const char *func, const char *assertion)
Helper for CHECK_NONFATAL()
NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
constexpr 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)
Helper for Assert()/Assume()
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
Helper for Assert()
#define T(expected, seed, data)