From a28343a33ed28b4d5c83c37e350aceaf09b5246f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 5 Dec 2019 13:09:21 -0600 Subject: Add string parameter to WASM_UNREACHABLE (#2499) This works more like llvm's unreachable handler in that is preserves information even in release builds. --- src/support/utilities.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/support/utilities.h') 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 -- cgit v1.2.3