|
@@ -4,10 +4,13 @@
|
|
|
|
|
|
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
|
|
-#include <cstdlib>
|
|
|
|
|
-#include "common/common_funcs.h"
|
|
|
|
|
#include "common/logging/log.h"
|
|
#include "common/logging/log.h"
|
|
|
|
|
|
|
|
|
|
+// Sometimes we want to try to continue even after hitting an assert.
|
|
|
|
|
+// However touching this file yields a global recompilation as this header is included almost
|
|
|
|
|
+// everywhere. So let's just move the handling of the failed assert to a single cpp file.
|
|
|
|
|
+void assert_handle_failure();
|
|
|
|
|
+
|
|
|
// For asserts we'd like to keep all the junk executed when an assert happens away from the
|
|
// 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
|
|
// 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
|
|
// lambda and force the compiler to not inline it. Unfortunately, MSVC seems to have no syntax to
|
|
@@ -17,15 +20,14 @@
|
|
|
// enough for our purposes.
|
|
// enough for our purposes.
|
|
|
template <typename Fn>
|
|
template <typename Fn>
|
|
|
#if defined(_MSC_VER)
|
|
#if defined(_MSC_VER)
|
|
|
-[[msvc::noinline, noreturn]]
|
|
|
|
|
|
|
+[[msvc::noinline]]
|
|
|
#elif defined(__GNUC__)
|
|
#elif defined(__GNUC__)
|
|
|
-[[gnu::cold, gnu::noinline, noreturn]]
|
|
|
|
|
|
|
+[[gnu::cold, gnu::noinline]]
|
|
|
#endif
|
|
#endif
|
|
|
static void
|
|
static void
|
|
|
assert_noinline_call(const Fn& fn) {
|
|
assert_noinline_call(const Fn& fn) {
|
|
|
fn();
|
|
fn();
|
|
|
- Crash();
|
|
|
|
|
- exit(1); // Keeps GCC's mouth shut about this actually returning
|
|
|
|
|
|
|
+ assert_handle_failure();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#define ASSERT(_a_) \
|
|
#define ASSERT(_a_) \
|