summaryrefslogtreecommitdiff
path: root/src/support/utilities.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/support/utilities.h')
-rw-r--r--src/support/utilities.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/support/utilities.h b/src/support/utilities.h
index 71d8ce2e0..5280fcb3b 100644
--- a/src/support/utilities.h
+++ b/src/support/utilities.h
@@ -74,6 +74,20 @@ public:
}
};
+WASM_NORETURN void handle_unreachable(const char* msg = nullptr,
+ const char* file = nullptr,
+ unsigned line = 0);
+
+// If control flow reaches the point of the WASM_UNREACHABLE(), the program is
+// undefined.
+#ifndef NDEBUG
+#define WASM_UNREACHABLE(msg) wasm::handle_unreachable(msg, __FILE__, __LINE__)
+#elif defined(WASM_BUILTIN_UNREACHABLE)
+#define WASM_UNREACHABLE(msg) WASM_BUILTIN_UNREACHABLE
+#else
+#define WASM_UNREACHABLE(msg) wasm::handle_unreachable()
+#endif
+
} // namespace wasm
#endif // wasm_support_utilities_h