LLVM 20.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
ErrorHandling.h File Reference
#include "llvm/Support/Compiler.h"

Go to the source code of this file.

Classes

struct  llvm::ScopedFatalErrorHandler
 ScopedFatalErrorHandler - This is a simple helper class which just calls install_fatal_error_handler in its constructor and remove_fatal_error_handler in its destructor. More...
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Macros

#define llvm_unreachable(msg)    ::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)
 Marks that the current location is not supposed to be reachable.
 

Typedefs

typedef void(* llvm::fatal_error_handler_t) (void *user_data, const char *reason, bool gen_crash_diag)
 An error handler callback.
 

Functions

void llvm::install_fatal_error_handler (fatal_error_handler_t handler, void *user_data=nullptr)
 install_fatal_error_handler - Installs a new error handler to be used whenever a serious (non-recoverable) error is encountered by LLVM.
 
void llvm::remove_fatal_error_handler ()
 Restores default error handling behaviour.
 
void llvm::report_fatal_error (const char *reason, bool gen_crash_diag=true)
 Reports a serious error, calling any installed error handler.
 
void llvm::report_fatal_error (StringRef reason, bool gen_crash_diag=true)
 
void llvm::report_fatal_error (const Twine &reason, bool gen_crash_diag=true)
 
void llvm::install_bad_alloc_error_handler (fatal_error_handler_t handler, void *user_data=nullptr)
 Installs a new bad alloc error handler that should be used whenever a bad alloc error, e.g.
 
void llvm::remove_bad_alloc_error_handler ()
 Restores default bad alloc error handling behavior.
 
void llvm::install_out_of_memory_new_handler ()
 
void llvm::report_bad_alloc_error (const char *Reason, bool GenCrashDiag=true)
 Reports a bad alloc error, calling any user defined bad alloc error handler.
 
void llvm::llvm_unreachable_internal (const char *msg=nullptr, const char *file=nullptr, unsigned line=0)
 This function calls abort(), and prints the optional message to stderr.
 

Macro Definition Documentation

◆ llvm_unreachable

#define llvm_unreachable (   msg)     ::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)

Marks that the current location is not supposed to be reachable.

In !NDEBUG builds, prints the message and location info to stderr. In NDEBUG builds, if the platform does not support a builtin unreachable then we call an internal LLVM runtime function. Otherwise the behavior is controlled by the CMake flag -DLLVM_UNREACHABLE_OPTIMIZE

  • When "ON" (default) llvm_unreachable() becomes an optimizer hint that the current location is not supposed to be reachable: the hint turns such code path into undefined behavior. On compilers that don't support such hints, prints a reduced message instead and aborts the program.
  • When "OFF", a builtin_trap is emitted instead of an Use this instead of assert(0). It conveys intent more clearly, suppresses diagnostics for unreachable code paths, and allows compilers to omit unnecessary code.

Definition at line 143 of file ErrorHandling.h.