summaryrefslogtreecommitdiff
path: root/src/support/utilities.h
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-12-05 13:09:21 -0600
committerGitHub <noreply@github.com>2019-12-05 13:09:21 -0600
commita28343a33ed28b4d5c83c37e350aceaf09b5246f (patch)
tree084a487cdf79e8025246d2a85d5578c113c9ad51 /src/support/utilities.h
parentcbf121df96cfce5038f52ed04f9780e19ed3b762 (diff)
downloadbinaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.tar.gz
binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.tar.bz2
binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.zip
Add string parameter to WASM_UNREACHABLE (#2499)
This works more like llvm's unreachable handler in that is preserves information even in release builds.
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