18#include "llvm/Config/config.h"
32#if defined(HAVE_UNISTD_H)
48#if LLVM_ENABLE_THREADS == 1
60static std::mutex ErrorHandlerMutex;
61static std::mutex BadAllocErrorHandlerMutex;
66#if LLVM_ENABLE_THREADS == 1
67 std::lock_guard<std::mutex> Lock(ErrorHandlerMutex);
75#if LLVM_ENABLE_THREADS == 1
76 std::lock_guard<std::mutex> Lock(ErrorHandlerMutex);
92 void* handlerData =
nullptr;
96#if LLVM_ENABLE_THREADS == 1
97 std::lock_guard<std::mutex> Lock(ErrorHandlerMutex);
104 handler(handlerData, Reason.
str().c_str(), GenCrashDiag);
111 OS <<
"LLVM ERROR: " << Reason <<
"\n";
130#if LLVM_ENABLE_THREADS == 1
131 std::lock_guard<std::mutex> Lock(BadAllocErrorHandlerMutex);
134 "Bad alloc error handler already registered!\n");
140#if LLVM_ENABLE_THREADS == 1
141 std::lock_guard<std::mutex> Lock(BadAllocErrorHandlerMutex);
149 void *HandlerData =
nullptr;
153#if LLVM_ENABLE_THREADS == 1
154 std::lock_guard<std::mutex> Lock(BadAllocErrorHandlerMutex);
161 Handler(HandlerData, Reason, GenCrashDiag);
165#ifdef LLVM_ENABLE_EXCEPTIONS
167 throw std::bad_alloc();
171 const char *OOMMessage =
"LLVM ERROR: out of memory\n";
172 const char *Newline =
"\n";
173 (void)!
::write(2, OOMMessage, strlen(OOMMessage));
174 (void)!
::write(2, Reason, strlen(Reason));
175 (void)!
::write(2, Newline, strlen(Newline));
180#ifdef LLVM_ENABLE_EXCEPTIONS
198 "new-handler already installed");
208 dbgs() << msg <<
"\n";
209 dbgs() <<
"UNREACHABLE executed";
211 dbgs() <<
" at " <<
file <<
":" << line;
214#ifdef LLVM_BUILTIN_UNREACHABLE
217 LLVM_BUILTIN_UNREACHABLE;
222 bool gen_crash_diag) {
239#define WIN32_NO_STATUS
241#undef WIN32_NO_STATUS
257extern "C" NTSYSAPI NTSTATUS NTAPI RtlGetLastNtStatus();
263 unsigned EV = ::GetLastError();
267 if (EV == ERROR_ACCESS_DENIED) {
268 llvm::errc code = RtlGetLastNtStatus() == STATUS_DELETE_PENDING
269 ? errc::delete_pending
270 : errc::permission_denied;
277#define MAP_ERR_TO_COND(x, y) \
279 return make_error_code(errc::y)
284 MAP_ERR_TO_COND(ERROR_ALREADY_EXISTS,
file_exists);
293 MAP_ERR_TO_COND(ERROR_CANTOPEN,
io_error);
294 MAP_ERR_TO_COND(ERROR_CANTREAD,
io_error);
295 MAP_ERR_TO_COND(ERROR_CANTWRITE,
io_error);
318 MAP_ERR_TO_COND(ERROR_OPEN_FAILED,
io_error);
322 MAP_ERR_TO_COND(ERROR_READ_FAULT,
io_error);
325 MAP_ERR_TO_COND(ERROR_SEEK,
io_error);
328 MAP_ERR_TO_COND(ERROR_WRITE_FAULT,
io_error);
338 return std::error_code(EV, std::system_category());
#define LLVM_EXTENSION
LLVM_EXTENSION - Support compilers where we have a keyword to suppress pedantic diagnostics.
static fatal_error_handler_t ErrorHandler
static void out_of_memory_new_handler()
static void bindingsErrorHandler(void *user_data, const char *reason, bool gen_crash_diag)
static fatal_error_handler_t BadAllocErrorHandler
static void * BadAllocErrorHandlerUserData
static void * ErrorHandlerUserData
Provides a library for accessing information about this process and other processes on the operating ...
dot regions Print regions of function to dot file(with no function bodies)"
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
A raw_ostream that writes to an SmallVector or SmallString.
void LLVMResetFatalErrorHandler()
Reset the fatal error handler.
void(* LLVMFatalErrorHandler)(const char *Reason)
void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler)
Install a fatal error handler.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
This is an optimization pass for GlobalISel generic memory operations.
std::error_code make_error_code(BitcodeError E)
std::error_code mapLastWindowsError()
void(* fatal_error_handler_t)(void *user_data, const char *reason, bool gen_crash_diag)
An error handler callback.
void 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-recover...
void 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,...
void remove_bad_alloc_error_handler()
Restores default bad alloc error handling behavior.
@ no_such_file_or_directory
@ device_or_resource_busy
@ resource_unavailable_try_again
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void install_out_of_memory_new_handler()
void 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.
void remove_fatal_error_handler()
Restores default error handling behaviour.
std::error_code mapWindowsError(unsigned EV)
void report_bad_alloc_error(const char *Reason, bool GenCrashDiag=true)
Reports a bad alloc error, calling any user defined bad alloc error handler.