This commit is contained in:
Nikita Mikhaylov 2024-03-12 17:26:42 +00:00
parent 2781224d7a
commit f3f1f611a4
2 changed files with 9 additions and 2 deletions

View File

@ -108,16 +108,22 @@
{
[[noreturn]] void abortOnFailedAssertion(const String & description);
}
#define chassert(x) do { static_cast<bool>(x) ? void(0) : ::DB::abortOnFailedAssertion(#x); } while (0)
#define chassert_1(x, ...) do { static_cast<bool>(x) ? void(0) : ::DB::abortOnFailedAssertion(#x); } while (0)
#define chassert_2(x, comment, ...) do { static_cast<bool>(x) ? void(0) : ::DB::abortOnFailedAssertion(comment); } while (0)
#define UNREACHABLE() abort()
// clang-format off
#else
/// Here sizeof() trick is used to suppress unused warning for result,
/// since simple "(void)x" will evaluate the expression, while
/// "sizeof(!(x))" will not.
#define chassert(x) (void)sizeof(!(x))
#define chassert_1(x, ...) (void)sizeof(!(x))
#define chassert_2(x, comment, ...) (void)sizeof(!(x))
#define UNREACHABLE() __builtin_unreachable()
#endif
#define CHASSERT_IMPL(_1,_2, N,...) N(_1, _2)
#define CHASSERT_IMPL_(tuple) CHASSERT_IMPL tuple
#define chassert(...) CHASSERT_IMPL_((__VA_ARGS__, chassert_2, chassert_1))
#endif
/// Macros for Clang Thread Safety Analysis (TSA). They can be safely ignored by other compilers.

View File

@ -61,6 +61,7 @@ protected:
settings.ostr << '.';
}
chassert(table != nullptr, "Table is empty for the ASTQueryWithTableAndOutputImpl.");
table->formatImpl(settings, state, frame);
}
};