diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/ErrorHandling.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp index 9425445..a0b7619 100644 --- a/lib/Support/ErrorHandling.cpp +++ b/lib/Support/ErrorHandling.cpp @@ -20,6 +20,7 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" +#include "llvm-c/Core.h" #include <cassert> #include <cstdlib> @@ -102,3 +103,19 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file, LLVM_BUILTIN_UNREACHABLE; #endif } + +static void bindingsErrorHandler(void *user_data, const std::string& reason, + bool gen_crash_diag) { + LLVMFatalErrorHandler handler = + reinterpret_cast<LLVMFatalErrorHandler>(user_data); + handler(reason.c_str()); +} + +void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) { + install_fatal_error_handler( + bindingsErrorHandler, reinterpret_cast<void*>(Handler)); +} + +void LLVMResetFatalErrorHandler() { + remove_fatal_error_handler(); +} |