Add more information to the MG_ASSERT in release mode (#291)
This commit is contained in:
parent
47c0c629c7
commit
95dd3481c0
@ -203,7 +203,7 @@ Reader::ParsingResult Reader::ParseRow(utils::MemoryResource *mem) {
|
||||
// parse the header.
|
||||
// Also, if we don't have a header, the 'number_of_columns_' will be 0, so no
|
||||
// need to check the number of columns.
|
||||
if (UNLIKELY(number_of_columns_ != 0 && row.size() != number_of_columns_)) {
|
||||
if (number_of_columns_ != 0 && row.size() != number_of_columns_) [[unlikely]] {
|
||||
return ParseError(ParseError::ErrorCode::BAD_NUM_OF_COLUMNS,
|
||||
// ToDo(the-joksim):
|
||||
// - 'line_count_ - 1' is the last line of a row (as a
|
||||
|
@ -26,10 +26,8 @@
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "utils/likely.hpp"
|
||||
|
||||
namespace logging {
|
||||
#ifndef NDEBUG
|
||||
|
||||
// TODO (antonio2368): Replace with std::source_location when it's supported by
|
||||
// compilers
|
||||
template <typename... Args>
|
||||
@ -47,24 +45,12 @@ void AssertFailed(const char *file_name, int line_num, const char *expr, const A
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
// TODO (antonio2368): Replace with attribute [[likely]] when it's supported by
|
||||
// compilers
|
||||
#define MG_ASSERT(expr, ...) \
|
||||
LIKELY(!!(expr)) \
|
||||
? (void)0 : ::logging::AssertFailed(__FILE__, __LINE__, #expr, ##__VA_ARGS__)
|
||||
[[likely]] !!(expr) ? (void)0 : ::logging::AssertFailed(__FILE__, __LINE__, #expr, ##__VA_ARGS__)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DMG_ASSERT(expr, ...) MG_ASSERT(expr, __VA_ARGS__)
|
||||
#else
|
||||
template <typename... Args>
|
||||
void AssertFailed(const Args &...msg_args) {
|
||||
if constexpr (sizeof...(msg_args) > 0) {
|
||||
spdlog::critical("Assertion failed with message: '{}'", fmt::format(msg_args...).c_str());
|
||||
} else {
|
||||
spdlog::critical("Assertion failed");
|
||||
}
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
#define MG_ASSERT(expr, ...) LIKELY(!!(expr)) ? (void)0 : ::logging::AssertFailed(__VA_ARGS__)
|
||||
#define DMG_ASSERT(...)
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user