assert: Check for unreachable code if DYNARMIC_IGNORE_ASSERTS isn't enabled
This commit is contained in:
parent
5bf74b5f04
commit
9de58f2875
1 changed files with 14 additions and 12 deletions
|
@ -24,27 +24,29 @@ template <typename... Ts>
|
||||||
|
|
||||||
} // namespace Dynarmic::Common
|
} // namespace Dynarmic::Common
|
||||||
|
|
||||||
#if defined(NDEBUG)
|
#if defined(__clang) || defined(__GNUC__)
|
||||||
#if defined(__clang) || defined(__GNUC__)
|
#define ASSUME(expr) [&]{ if (!(expr)) __builtin_unreachable(); }()
|
||||||
#define UNREACHABLE() __builtin_unreachable()
|
#elif defined(_MSC_VER)
|
||||||
#define ASSUME(expr) [&]{ if (!(expr)) __builtin_unreachable(); }()
|
#define ASSUME(expr) __assume(expr)
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define UNREACHABLE() __assume(0)
|
|
||||||
#define ASSUME(expr) __assume(expr)
|
|
||||||
#else
|
|
||||||
#define UNREACHABLE() ASSERT_FALSE("Unreachable code!")
|
|
||||||
#define ASSUME(expr)
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define UNREACHABLE() ASSERT_FALSE("Unreachable code!")
|
|
||||||
#define ASSUME(expr)
|
#define ASSUME(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DYNARMIC_IGNORE_ASSERTS
|
#ifdef DYNARMIC_IGNORE_ASSERTS
|
||||||
|
#if defined(__clang) || defined(__GNUC__)
|
||||||
|
#define UNREACHABLE() __builtin_unreachable()
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#define UNREACHABLE() __assume(0)
|
||||||
|
#else
|
||||||
|
#define UNREACHABLE()
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ASSERT(expr) ASSUME(expr)
|
#define ASSERT(expr) ASSUME(expr)
|
||||||
#define ASSERT_MSG(expr, ...) ASSUME(expr)
|
#define ASSERT_MSG(expr, ...) ASSUME(expr)
|
||||||
#define ASSERT_FALSE(...) UNREACHABLE()
|
#define ASSERT_FALSE(...) UNREACHABLE()
|
||||||
#else
|
#else
|
||||||
|
#define UNREACHABLE() ASSERT_FALSE("Unreachable code!")
|
||||||
|
|
||||||
#define ASSERT(expr) \
|
#define ASSERT(expr) \
|
||||||
[&]{ \
|
[&]{ \
|
||||||
if (UNLIKELY(!(expr))) { \
|
if (UNLIKELY(!(expr))) { \
|
||||||
|
|
Loading…
Reference in a new issue