aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-10-26 16:28:50 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-10-26 16:58:36 +0200
commitfaa769db5a4c16fd171e9a39c33e245db4e7c134 (patch)
treec8be7a3ee3ab45ca85474edfa995a4af5008d7d2 /src/util
parent2a349f9ea5de9f0157cd117289996e8640473a6d (diff)
downloadbitcoin-faa769db5a4c16fd171e9a39c33e245db4e7c134.tar.xz
Fix bugprone-lambda-function-name errors
Can be reviewed with --color-moved=dimmed-zebra
Diffstat (limited to 'src/util')
-rw-r--r--src/util/check.h37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/util/check.h b/src/util/check.h
index 7ddcebf506..00951dec89 100644
--- a/src/util/check.h
+++ b/src/util/check.h
@@ -20,8 +20,6 @@ public:
NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func);
};
-#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
-
/** Helper for CHECK_NONFATAL() */
template <typename T>
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion)
@@ -32,20 +30,6 @@ T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, co
return std::forward<T>(val);
}
-/**
- * Identity function. Throw a NonFatalCheckError when the condition evaluates to false
- *
- * This should only be used
- * - where the condition is assumed to be true, not for error handling or validating user input
- * - where a failure to fulfill the condition is recoverable and does not abort the program
- *
- * For example in RPC code, where it is undesirable to crash the whole program, this can be generally used to replace
- * asserts or recoverable logic errors. A NonFatalCheckError in RPC code is caught and passed as a string to the RPC
- * caller, which can then report the issue to the developers.
- */
-#define CHECK_NONFATAL(condition) \
- inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
-
#if defined(NDEBUG)
#error "Cannot compile without assertions!"
#endif
@@ -69,6 +53,25 @@ T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* f
return std::forward<T>(val);
}
+// All macros may use __func__ inside a lambda, so put them under nolint.
+// NOLINTBEGIN(bugprone-lambda-function-name)
+
+#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
+
+/**
+ * Identity function. Throw a NonFatalCheckError when the condition evaluates to false
+ *
+ * This should only be used
+ * - where the condition is assumed to be true, not for error handling or validating user input
+ * - where a failure to fulfill the condition is recoverable and does not abort the program
+ *
+ * For example in RPC code, where it is undesirable to crash the whole program, this can be generally used to replace
+ * asserts or recoverable logic errors. A NonFatalCheckError in RPC code is caught and passed as a string to the RPC
+ * caller, which can then report the issue to the developers.
+ */
+#define CHECK_NONFATAL(condition) \
+ inline_check_non_fatal(condition, __FILE__, __LINE__, __func__, #condition)
+
/** Identity function. Abort if the value compares equal to zero */
#define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
@@ -91,4 +94,6 @@ T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* f
throw NonFatalCheckError( \
"Unreachable code reached (non-fatal)", __FILE__, __LINE__, __func__)
+// NOLINTEND(bugprone-lambda-function-name)
+
#endif // BITCOIN_UTIL_CHECK_H