/Users/eugenesiegel/btc/bitcoin/src/util/check.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2019-2022 The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_UTIL_CHECK_H |
6 | | #define BITCOIN_UTIL_CHECK_H |
7 | | |
8 | | #include <attributes.h> |
9 | | |
10 | | #include <atomic> |
11 | | #include <cassert> // IWYU pragma: export |
12 | | #include <stdexcept> |
13 | | #include <string> |
14 | | #include <string_view> |
15 | | #include <utility> |
16 | | |
17 | | constexpr bool G_FUZZING_BUILD{ |
18 | | #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
19 | | true |
20 | | #else |
21 | | false |
22 | | #endif |
23 | | }; |
24 | | constexpr bool G_ABORT_ON_FAILED_ASSUME{ |
25 | | #ifdef ABORT_ON_FAILED_ASSUME |
26 | | true |
27 | | #else |
28 | | false |
29 | | #endif |
30 | | }; |
31 | | |
32 | | extern std::atomic<bool> g_enable_dynamic_fuzz_determinism; |
33 | | |
34 | | inline bool EnableFuzzDeterminism() |
35 | 41.6M | { |
36 | 41.6M | if constexpr (G_FUZZING_BUILD) { |
37 | 41.6M | return true; |
38 | | } else if constexpr (!G_ABORT_ON_FAILED_ASSUME) { |
39 | | // Running fuzz tests is always disabled if Assume() doesn't abort |
40 | | // (ie, non-fuzz non-debug builds), as otherwise tests which |
41 | | // should fail due to a failing Assume may still pass. As such, |
42 | | // we also statically disable fuzz determinism in that case. |
43 | | return false; |
44 | | } else { |
45 | | return g_enable_dynamic_fuzz_determinism; |
46 | | } |
47 | 41.6M | } |
48 | | |
49 | | std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func); |
50 | | |
51 | | class NonFatalCheckError : public std::runtime_error |
52 | | { |
53 | | public: |
54 | | NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func); |
55 | | }; |
56 | | |
57 | | /** Helper for CHECK_NONFATAL() */ |
58 | | template <typename T> |
59 | | T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion) |
60 | 5.19M | { |
61 | 5.19M | if (!val) { |
62 | 0 | throw NonFatalCheckError{assertion, file, line, func}; |
63 | 0 | } |
64 | 5.19M | return std::forward<T>(val); |
65 | 5.19M | } _Z22inline_check_non_fatalIbEOT_S1_PKciS3_S3_ Line | Count | Source | 60 | 5.19M | { | 61 | 5.19M | if (!val) { | 62 | 0 | throw NonFatalCheckError{assertion, file, line, func}; | 63 | 0 | } | 64 | 5.19M | return std::forward<T>(val); | 65 | 5.19M | } |
Unexecuted instantiation: _Z22inline_check_non_fatalIRKbEOT_S3_PKciS5_S5_ Unexecuted instantiation: _Z22inline_check_non_fatalIRbEOT_S2_PKciS4_S4_ Unexecuted instantiation: _Z22inline_check_non_fatalIRPK14JSONRPCRequestEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalIRPK8UniValueEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalINSt3__18optionalI13arith_uint256EEEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalIRPN6wallet25DescriptorScriptPubKeyManEEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalINSt3__110unique_ptrI16CCoinsViewCursorNS0_14default_deleteIS2_EEEEEOT_S7_PKciS9_S9_ Unexecuted instantiation: _Z22inline_check_non_fatalIRPK11CBlockIndexEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalIPN4node12BlockManagerEEOT_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_check_non_fatalINSt3__110shared_ptrIK12CTransactionEEEOT_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_check_non_fatalIRP11CBlockIndexEOT_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_check_non_fatalINSt3__18optionalIN10interfaces8BlockRefEEEEOT_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_check_non_fatalIRNSt3__110unique_ptrI17ValidationSignalsNS0_14default_deleteIS2_EEEEEOT_S8_PKciSA_SA_ Unexecuted instantiation: _Z22inline_check_non_fatalIP11CBlockIndexEOT_S3_PKciS5_S5_ Unexecuted instantiation: _Z22inline_check_non_fatalIPK11CBlockIndexEOT_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_check_non_fatalIRKP11CBlockIndexEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalIRNSt3__110unique_ptrIN4node8WarningsENS0_14default_deleteIS3_EEEEEOT_S9_PKciSB_SB_ Unexecuted instantiation: _Z22inline_check_non_fatalIRNSt3__18optionalIN6kernel11CCoinsStatsEEEEOT_S7_PKciS9_S9_ Unexecuted instantiation: _Z22inline_check_non_fatalIRKP17ValidationSignalsEOT_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_check_non_fatalIRKNSt3__110unique_ptrI17ValidationSignalsNS0_14default_deleteIS2_EEEEEOT_S9_PKciSB_SB_ Unexecuted instantiation: _Z22inline_check_non_fatalIRNSt3__110unique_ptrIN10interfaces13BlockTemplateENS0_14default_deleteIS3_EEEEEOT_S9_PKciSB_SB_ Unexecuted instantiation: _Z22inline_check_non_fatalIRKNSt3__110unique_ptrI10CSchedulerNS0_14default_deleteIS2_EEEEEOT_S9_PKciSB_SB_ Unexecuted instantiation: _Z22inline_check_non_fatalIRNSt3__18functionIFbvEEEEOT_S6_PKciS8_S8_ |
66 | | |
67 | | #if defined(NDEBUG) |
68 | | #error "Cannot compile without assertions!" |
69 | | #endif |
70 | | |
71 | | /** Helper for Assert() */ |
72 | | void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion); |
73 | | |
74 | | /** Helper for Assert()/Assume() */ |
75 | | template <bool IS_ASSERT, typename T> |
76 | | 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) |
77 | 858M | { |
78 | 858M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { |
79 | 858M | if (!val) { |
80 | 0 | assertion_fail(file, line, func, assertion); |
81 | 0 | } |
82 | 858M | } |
83 | 858M | return std::forward<T>(val); |
84 | 858M | } _Z22inline_assertion_checkILb0EbEOT0_S1_PKciS3_S3_ Line | Count | Source | 77 | 211M | { | 78 | 211M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 211M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 211M | } | 83 | 211M | return std::forward<T>(val); | 84 | 211M | } |
_Z22inline_assertion_checkILb0EiEOT0_S1_PKciS3_S3_ Line | Count | Source | 77 | 29.9M | { | 78 | 29.9M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 29.9M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 29.9M | } | 83 | 29.9M | return std::forward<T>(val); | 84 | 29.9M | } |
_Z22inline_assertion_checkILb0ERKhEOT0_S3_PKciS5_S5_ Line | Count | Source | 77 | 20.1M | { | 78 | 20.1M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 20.1M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 20.1M | } | 83 | 20.1M | return std::forward<T>(val); | 84 | 20.1M | } |
_Z22inline_assertion_checkILb1ERKNSt3__110unique_ptrI14LevelDBContextNS0_14default_deleteIS2_EEEEEOT0_S9_PKciSB_SB_ Line | Count | Source | 77 | 83.6M | { | 78 | 83.6M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 83.6M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 83.6M | } | 83 | 83.6M | return std::forward<T>(val); | 84 | 83.6M | } |
_Z22inline_assertion_checkILb1ERNSt3__110unique_ptrI10CoinsViewsNS0_14default_deleteIS2_EEEEEOT0_S8_PKciSA_SA_ Line | Count | Source | 77 | 130M | { | 78 | 130M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 130M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 130M | } | 83 | 130M | return std::forward<T>(val); | 84 | 130M | } |
_Z22inline_assertion_checkILb1ERNSt3__110unique_ptrI15CCoinsViewCacheNS0_14default_deleteIS2_EEEEEOT0_S8_PKciSA_SA_ Line | Count | Source | 77 | 130M | { | 78 | 130M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 130M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 130M | } | 83 | 130M | return std::forward<T>(val); | 84 | 130M | } |
_Z22inline_assertion_checkILb1ERKNSt3__18optionalI13arith_uint256EEEOT0_S7_PKciS9_S9_ Line | Count | Source | 77 | 70.6M | { | 78 | 70.6M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 70.6M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 70.6M | } | 83 | 70.6M | return std::forward<T>(val); | 84 | 70.6M | } |
_Z22inline_assertion_checkILb1ERKNSt3__18optionalI7uint256EEEOT0_S7_PKciS9_S9_ Line | Count | Source | 77 | 20.0M | { | 78 | 20.0M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 20.0M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 20.0M | } | 83 | 20.0M | return std::forward<T>(val); | 84 | 20.0M | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb0ERbEOT0_S2_PKciS4_S4_ Unexecuted instantiation: _Z22inline_assertion_checkILb0ERmEOT0_S2_PKciS4_S4_ Unexecuted instantiation: _Z22inline_assertion_checkILb1E10MinisketchEOT0_S2_PKciS4_S4_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalINS0_6vectorIyNS0_9allocatorIyEEEEEEEOT0_S8_PKciSA_SA_ _Z22inline_assertion_checkILb1EbEOT0_S1_PKciS3_S3_ Line | Count | Source | 77 | 40.0M | { | 78 | 40.0M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 40.0M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 40.0M | } | 83 | 40.0M | return std::forward<T>(val); | 84 | 40.0M | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb1ERbEOT0_S2_PKciS4_S4_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERPK13MappingResultEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EPK15CTxMemPoolEntryEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ElEOT0_S1_PKciS3_S3_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKbEOT0_S3_PKciS5_S5_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKNSt3__18optionalIxEEEOT0_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKNSt3__18optionalI8CFeeRateEEEOT0_S7_PKciS9_S9_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKNSt3__18optionalINS0_6vectorI22transaction_identifierILb1EENS0_9allocatorIS4_EEEEEEEOT0_SC_PKciSE_SE_ _Z22inline_assertion_checkILb1ERPK11CBlockIndexEOT0_S5_PKciS7_S7_ Line | Count | Source | 77 | 67.3k | { | 78 | 67.3k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 67.3k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 67.3k | } | 83 | 67.3k | return std::forward<T>(val); | 84 | 67.3k | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalIN6kernel11CCoinsStatsEEEEOT0_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalI14AssumeutxoDataEEEOT0_S5_PKciS7_S7_ _Z22inline_assertion_checkILb1ERNSt3__110unique_ptrI17ChainstateManagerNS0_14default_deleteIS2_EEEEEOT0_S8_PKciSA_SA_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb0ERKmEOT0_S3_PKciS5_S5_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalIiEEEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EN4util6ResultIPN6wallet15ScriptPubKeyManEEEEOT0_S7_PKciS9_S9_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalI10OutputTypeEEEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EN4util6ResultINSt3__17variantIJ14CNoDestination17PubKeyDestination6PKHash10ScriptHash19WitnessV0ScriptHash16WitnessV0KeyHash16WitnessV1Taproot11PayToAnchor14WitnessUnknownEEEEEEOT0_SG_PKciSI_SI_ _Z22inline_assertion_checkILb1ERPKNSt3__18functionIFvNS0_4spanIKhLm18446744073709551615EEEEEEEOT0_SB_PKciSD_SD_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
_Z22inline_assertion_checkILb1ERNSt3__18functionIFvNS0_4spanIKhLm18446744073709551615EEEEEEEOT0_S9_PKciSB_SB_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKNSt3__18optionalIN2fs4pathEEEEOT0_S8_PKciSA_SA_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERNSt3__18optionalI19CMutableTransactionEEEOT0_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERP10CSchedulerEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERP11ArgsManagerEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EPKN6wallet9CWalletTxEEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERNSt3__110unique_ptrIN6wallet17SQliteExecHandlerENS0_14default_deleteIS3_EEEEEOT0_S9_PKciSB_SB_ _Z22inline_assertion_checkILb1ERKPK7uint256EOT0_S6_PKciS8_S8_ Line | Count | Source | 77 | 19.9M | { | 78 | 19.9M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 19.9M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 19.9M | } | 83 | 19.9M | return std::forward<T>(val); | 84 | 19.9M | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb0ERPN6wallet14LegacyDataSPKMEEOT0_S5_PKciS7_S7_ _Z22inline_assertion_checkILb1ERKNSt3__110unique_ptrI17ChainstateManagerNS0_14default_deleteIS2_EEEEEOT0_S9_PKciSB_SB_ Line | Count | Source | 77 | 29.9M | { | 78 | 29.9M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 29.9M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 29.9M | } | 83 | 29.9M | return std::forward<T>(val); | 84 | 29.9M | } |
_Z22inline_assertion_checkILb1EP10CTxMemPoolEOT0_S3_PKciS5_S5_ Line | Count | Source | 77 | 10.0M | { | 78 | 10.0M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 10.0M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 10.0M | } | 83 | 10.0M | return std::forward<T>(val); | 84 | 10.0M | } |
_Z22inline_assertion_checkILb1ERNSt3__16atomicIbEEEOT0_S5_PKciS7_S7_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
_Z22inline_assertion_checkILb1ERNSt3__18functionIFbvEEEEOT0_S6_PKciS8_S8_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
_Z22inline_assertion_checkILb1ERNSt3__110unique_ptrIN4node8WarningsENS0_14default_deleteIS3_EEEEEOT0_S9_PKciSB_SB_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
_Z22inline_assertion_checkILb1ERPN4util15SignalInterruptEEOT0_S5_PKciS7_S7_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
_Z22inline_assertion_checkILb1ERKN4util6ResultIvEEEOT0_S6_PKciS8_S8_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb1EPK11CBlockIndexEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EP17evhttp_connectionEOT0_S3_PKciS5_S5_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERP14evhttp_requestEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERPK17evhttp_connectionEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKPK6CBlockEOT0_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalI7uint256EEEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERNSt3__18optionalIN4util15SignalInterruptEEEEOT0_S7_PKciS9_S9_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EN4util6ResultIvEEEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERNSt3__110unique_ptrI17ValidationSignalsNS0_14default_deleteIS2_EEEEEOT0_S8_PKciSA_SA_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EP11CBlockIndexEOT0_S3_PKciS5_S5_ _Z22inline_assertion_checkILb1ERP11CBlockIndexEOT0_S4_PKciS6_S6_ Line | Count | Source | 77 | 10.0M | { | 78 | 10.0M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 10.0M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 10.0M | } | 83 | 10.0M | return std::forward<T>(val); | 84 | 10.0M | } |
net_processing.cpp:_Z22inline_assertion_checkILb1EPN12_GLOBAL__N_110CNodeStateEEOT0_S4_PKciS6_S6_ Line | Count | Source | 77 | 47.8k | { | 78 | 47.8k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 47.8k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 47.8k | } | 83 | 47.8k | return std::forward<T>(val); | 84 | 47.8k | } |
Unexecuted instantiation: net_processing.cpp:_Z22inline_assertion_checkILb1ENSt3__110shared_ptrIN12_GLOBAL__N_14PeerEEEEOT0_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERKNSt3__18optionalI14AssumeutxoDataEEEOT0_S7_PKciS9_S9_ _Z22inline_assertion_checkILb1ERNSt3__18optionalIN4node15BlockfileCursorEEEEOT0_S7_PKciS9_S9_ Line | Count | Source | 77 | 9.99M | { | 78 | 9.99M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 9.99M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 9.99M | } | 83 | 9.99M | return std::forward<T>(val); | 84 | 9.99M | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb1ERPN4node11NodeContextEEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1EPN4node11NodeContextEEOT0_S4_PKciS6_S6_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERPN10interfaces12WalletLoaderEEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ERNSt3__110unique_ptrIN4node19KernelNotificationsENS0_14default_deleteIS3_EEEEEOT0_S9_PKciSB_SB_ Unexecuted instantiation: _Z22inline_assertion_checkILb0ENSt3__18optionalI7uint256EEEOT0_S5_PKciS7_S7_ Unexecuted instantiation: _Z22inline_assertion_checkILb0ERKNSt3__18optionalI7uint256EEEOT0_S7_PKciS9_S9_ _Z22inline_assertion_checkILb1ERKPK10CTxMemPoolEOT0_S6_PKciS8_S8_ Line | Count | Source | 77 | 9.99M | { | 78 | 9.99M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 9.99M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 9.99M | } | 83 | 9.99M | return std::forward<T>(val); | 84 | 9.99M | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb0ERKbEOT0_S3_PKciS5_S5_ Unexecuted instantiation: _Z22inline_assertion_checkILb0ERPKN7TxGraph3RefEEOT0_S6_PKciS8_S8_ Unexecuted instantiation: _Z22inline_assertion_checkILb0ERN4util6ResultINSt3__13setIN5boost11multi_index6detail21hashed_index_iteratorINS6_17hashed_index_nodeINS8_INS6_18ordered_index_nodeINS6_19null_augment_policyENS9_ISA_NS9_ISA_NS6_15index_node_baseI15CTxMemPoolEntryNS2_9allocatorISC_EEEEEEEEEEEEEENS6_12bucket_arrayISE_EENS6_17hashed_unique_tagENS6_32hashed_index_global_iterator_tagEEE21CompareIteratorByHashNSD_ISP_EEEEEEEOT0_SW_PKciSY_SY_ Unexecuted instantiation: _Z22inline_assertion_checkILb0EN4util6ResultINSt3__13setIN5boost11multi_index6detail21hashed_index_iteratorINS6_17hashed_index_nodeINS8_INS6_18ordered_index_nodeINS6_19null_augment_policyENS9_ISA_NS9_ISA_NS6_15index_node_baseI15CTxMemPoolEntryNS2_9allocatorISC_EEEEEEEEEEEEEENS6_12bucket_arrayISE_EENS6_17hashed_unique_tagENS6_32hashed_index_global_iterator_tagEEE21CompareIteratorByHashNSD_ISP_EEEEEEEOT0_SV_PKciSX_SX_ Unexecuted instantiation: _Z22inline_assertion_checkILb0ERNSt3__110unique_ptrIN10CTxMemPool9ChangeSetENS0_14default_deleteIS3_EEEEEOT0_S9_PKciSB_SB_ _Z22inline_assertion_checkILb1ERKNSt3__18optionalIiEEEOT0_S6_PKciS8_S8_ Line | Count | Source | 77 | 30.1M | { | 78 | 30.1M | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 30.1M | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 30.1M | } | 83 | 30.1M | return std::forward<T>(val); | 84 | 30.1M | } |
Unexecuted instantiation: _Z22inline_assertion_checkILb1ERNSt3__110unique_ptrI10ChainstateNS0_14default_deleteIS2_EEEEEOT0_S8_PKciSA_SA_ Unexecuted instantiation: _Z22inline_assertion_checkILb1ENSt3__18optionalIN2fs4pathEEEEOT0_S6_PKciS8_S8_ _Z22inline_assertion_checkILb1ERNSt3__110unique_ptrIN4util19TaskRunnerInterfaceENS0_14default_deleteIS3_EEEEEOT0_S9_PKciSB_SB_ Line | Count | Source | 77 | 49.9k | { | 78 | 49.9k | if (IS_ASSERT || std::is_constant_evaluated()0 || G_FUZZING_BUILD0 || G_ABORT_ON_FAILED_ASSUME0 ) { | 79 | 49.9k | if (!val) { | 80 | 0 | assertion_fail(file, line, func, assertion); | 81 | 0 | } | 82 | 49.9k | } | 83 | 49.9k | return std::forward<T>(val); | 84 | 49.9k | } |
|
85 | | |
86 | | // All macros may use __func__ inside a lambda, so put them under nolint. |
87 | | // NOLINTBEGIN(bugprone-lambda-function-name) |
88 | | |
89 | 0 | #define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__) |
90 | | |
91 | | /** |
92 | | * Identity function. Throw a NonFatalCheckError when the condition evaluates to false |
93 | | * |
94 | | * This should only be used |
95 | | * - where the condition is assumed to be true, not for error handling or validating user input |
96 | | * - where a failure to fulfill the condition is recoverable and does not abort the program |
97 | | * |
98 | | * For example in RPC code, where it is undesirable to crash the whole program, this can be generally used to replace |
99 | | * asserts or recoverable logic errors. A NonFatalCheckError in RPC code is caught and passed as a string to the RPC |
100 | | * caller, which can then report the issue to the developers. |
101 | | */ |
102 | | #define CHECK_NONFATAL(condition) \ |
103 | 5.19M | inline_check_non_fatal(condition2.88k , __FILE__, __LINE__, __func__, #condition) Unexecuted instantiation: blockchain.cpp:_ZZL12GetUTXOStatsP10CCoinsViewRN4node12BlockManagerEN6kernel17CoinStatsHashTypeERKNSt3__18functionIFvvEEEPK11CBlockIndexbENK3$_0clEv Unexecuted instantiation: blockchain.cpp:_ZZZL10scanblocksvENK3$_0clERK10RPCHelpManRK14JSONRPCRequestENKUlvE0_clEv |
104 | | |
105 | | /** Identity function. Abort if the value compares equal to zero */ |
106 | 616M | #define Assert(val) inline_assertion_check<true>(val9.99M , __FILE__, __LINE__, __func__, #val) Unexecuted instantiation: txmempool.cpp:_ZZ31CheckMempoolEphemeralInvariantsRK10CTxMemPoolENK3$_0clERK5CTxIn blockstorage.cpp:_ZZN4node12BlockManager14WriteBlockUndoERK10CBlockUndoR20BlockValidationStateR11CBlockIndexENK3$_0clEv Line | Count | Source | 106 | 9.99M | #define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val) |
|
107 | | |
108 | | /** |
109 | | * Assume is the identity function. |
110 | | * |
111 | | * - Should be used to run non-fatal checks. In debug builds it behaves like |
112 | | * Assert()/assert() to notify developers and testers about non-fatal errors. |
113 | | * In production it doesn't warn or log anything. |
114 | | * - For fatal errors, use Assert(). |
115 | | * - For non-fatal errors in interactive sessions (e.g. RPC or command line |
116 | | * interfaces), CHECK_NONFATAL() might be more appropriate. |
117 | | */ |
118 | 261M | #define Assume(val) inline_assertion_check<false>(val150M , __FILE__, __LINE__, __func__, #val) Unexecuted instantiation: scriptpubkeyman.cpp:_ZZNK6wallet25DescriptorScriptPubKeyMan6GetKeyERK6CKeyIDENK3$_0clERKNSt3__16vectorIh16secure_allocatorIhEEE Unexecuted instantiation: wallet.cpp:_ZZNK6wallet7CWallet19GetScriptPubKeyMansERK7CScriptENK3$_0clEPNS_15ScriptPubKeyManE net_processing.cpp:_ZZN12_GLOBAL__N_115PeerManagerImpl14ProcessMessageER5CNodeRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEER10DataStreamNS3_6chrono8durationIxNS3_5ratioILl1ELl1000000EEEEERKNS3_6atomicIbEEENK3$_1clEv Line | Count | Source | 118 | 56.1k | #define Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val) |
Unexecuted instantiation: mini_miner.cpp:_ZZNK4node9MiniMiner11SanityCheckEvENK3$_0clINSt3__114__map_iteratorINS3_15__tree_iteratorINS3_12__value_typeI7uint256NS_21MiniMinerMempoolEntryEEEPNS3_11__tree_nodeIS9_PvEElEEEEEEDaRKT_ Unexecuted instantiation: mini_miner.cpp:_ZZNK4node9MiniMiner11SanityCheckEvENK3$_1clI7uint256EEDaRKT_ Unexecuted instantiation: ephemeral_policy.cpp:_ZZ20CheckEphemeralSpendsRKNSt3__16vectorINS_10shared_ptrIK12CTransactionEENS_9allocatorIS4_EEEE8CFeeRateRK10CTxMemPoolR17TxValidationStateR22transaction_identifierILb1EEENK3$_0clIS4_EEDaRKT_ |
119 | | |
120 | | /** |
121 | | * NONFATAL_UNREACHABLE() is a macro that is used to mark unreachable code. It throws a NonFatalCheckError. |
122 | | */ |
123 | | #define NONFATAL_UNREACHABLE() \ |
124 | 0 | throw NonFatalCheckError( \ |
125 | 0 | "Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__) |
126 | | |
127 | | // NOLINTEND(bugprone-lambda-function-name) |
128 | | |
129 | | #endif // BITCOIN_UTIL_CHECK_H |