diff options
author | Liam <byteslice@airmail.cc> | 2022-06-07 23:02:29 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2022-06-14 02:09:00 +0200 |
commit | 084d7d6b014443be7625fb9d8f1ddd309a22f6f4 (patch) | |
tree | ea48c7b1d22a0b282846ba28a9b62c988e38bd29 /src/common | |
parent | Merge pull request #8458 from lat9nq/no-constexpr-flow-block (diff) | |
download | yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.tar yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.tar.gz yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.tar.bz2 yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.tar.lz yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.tar.xz yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.tar.zst yuzu-084d7d6b014443be7625fb9d8f1ddd309a22f6f4.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/assert.cpp | 5 | ||||
-rw-r--r-- | src/common/assert.h | 14 | ||||
-rw-r--r-- | src/common/settings.cpp | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/common/assert.cpp b/src/common/assert.cpp index b44570528..a27a025ae 100644 --- a/src/common/assert.cpp +++ b/src/common/assert.cpp @@ -11,3 +11,8 @@ void assert_handle_failure() { Crash(); } } + +[[noreturn]] void unreachable_impl() { + Crash(); + throw std::runtime_error("Unreachable code"); +} diff --git a/src/common/assert.h b/src/common/assert.h index dbfd8abaf..478bfa856 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -11,6 +11,8 @@ // everywhere. So let's just move the handling of the failed assert to a single cpp file. void assert_handle_failure(); +[[noreturn]] void unreachable_impl(); + // For asserts we'd like to keep all the junk executed when an assert happens away from the // important code in the function. One way of doing this is to put all the relevant code inside a // lambda and force the compiler to not inline it. Unfortunately, MSVC seems to have no syntax to @@ -44,9 +46,17 @@ assert_noinline_call(const Fn& fn) { } \ while (0) -#define UNREACHABLE() assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!"); }) +#define UNREACHABLE() \ + do { \ + assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!"); }); \ + unreachable_impl(); \ + } while (0) + #define UNREACHABLE_MSG(...) \ - assert_noinline_call([&] { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); }) + do { \ + assert_noinline_call([&] { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); }); \ + unreachable_impl(); \ + } while (0) #ifdef _DEBUG #define DEBUG_ASSERT(_a_) ASSERT(_a_) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 6ffab63af..751549583 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -147,7 +147,7 @@ void UpdateRescalingInfo() { info.down_shift = 0; break; default: - UNREACHABLE(); + ASSERT(false); info.up_scale = 1; info.down_shift = 0; } |