1 //===- llvm/Support/ErrorHandling.h - Callbacks for errors ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines an API used to indicate error conditions.
11 // Callbacks can be registered for these errors through this API.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_ERRORHANDLING_H
16 #define LLVM_SUPPORT_ERRORHANDLING_H
18 #include "llvm/Support/Compiler.h"
21 // An error handler callback.
22 typedef void (*llvm_error_handler_t)(const std::string& reason);
24 // Installs a new error handler: this function will be called whenever a
25 // serious error is encountered by LLVM.
26 // If you are using llvm_start_multithreaded, you should register the handler
29 // If no error handler is installed the default is to print the error message
30 // to stderr, and call exit(1).
31 // If an error handler is installed then it is the handler's responsibility to
32 // log the message, it will no longer be printed to stderr.
33 // If the error handler returns, then exit(1) will be called.
34 void llvm_install_error_handler(llvm_error_handler_t handler);
36 // Restores default error handling behaviour.
37 // This must not be called between llvm_start_multithreaded() and
38 // llvm_stop_multithreaded().
39 void llvm_remove_error_handler(void);
41 // Reports a serious error, calling any installed error handler.
42 // If no error handler is installed the default is to print the message to
43 void llvm_report_error(const std::string &reason) NORETURN;
45 // This function calls abort().
46 // Call this after assert(0), so that compiler knows the path is not
48 void llvm_unreachable(void) NORETURN;