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 UNREACHABLE() __builtin_unreachable()
|
|
||||||
#define ASSUME(expr) [&]{ if (!(expr)) __builtin_unreachable(); }()
|
#define ASSUME(expr) [&]{ if (!(expr)) __builtin_unreachable(); }()
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define UNREACHABLE() __assume(0)
|
|
||||||
#define ASSUME(expr) __assume(expr)
|
#define ASSUME(expr) __assume(expr)
|
||||||
#else
|
#else
|
||||||
#define UNREACHABLE() ASSERT_FALSE("Unreachable code!")
|
|
||||||
#define ASSUME(expr)
|
|
||||||
#endif
|
|
||||||
#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