14 #include <system_error> 31 const char *
name()
const noexcept
override {
return "Error"; }
33 std::string message(
int condition)
const override {
34 switch (static_cast<ErrorErrorCode>(condition)) {
35 case ErrorErrorCode::MultipleErrors:
36 return "Multiple errors";
37 case ErrorErrorCode::InconvertibleError:
38 return "Inconvertible error value. An error has occurred that could " 39 "not be converted to a known std::error_code. Please file a " 41 case ErrorErrorCode::FileError:
42 return "A file error occurred.";
54 void ErrorInfoBase::anchor() {}
55 char ErrorInfoBase::ID = 0;
57 void ECError::anchor() {}
74 return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
79 return std::error_code(static_cast<int>(ErrorErrorCode::InconvertibleError),
84 return std::error_code(static_cast<int>(ErrorErrorCode::FileError),
104 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 105 void Error::fatalUncheckedError()
const {
106 dbgs() <<
"Program aborted due to an unhandled Error:\n";
110 dbgs() <<
"Error value was Success. (Note: Success values must still be " 111 "checked prior to being destroyed).\n";
117 : Msg(S.str()), EC(EC) {}
120 : Msg(S.str()), EC(EC), PrintMsgOnly(
true) {}
137 return make_error<StringError>(Msg, EC);
141 assert(Err &&
"report_fatal_error called with success value");
153 return reinterpret_cast<ErrorInfoBase *
>(Err)->dynamicClassID();
160 char *ErrMsg =
new char[Tmp.size() + 1];
161 memcpy(ErrMsg, Tmp.data(), Tmp.size());
162 ErrMsg[Tmp.size()] =
'\0';
178 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 179 int EnableABIBreakingChecks;
int DisableABIBreakingChecks
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
static const char * getPtr(const MachOObjectFile &O, size_t Offset)
StringError(std::error_code EC, const Twine &S=Twine())
block Block Frequency true
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Base class for error info classes.
This class wraps a filename and another Error.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Attribute unwrap(LLVMAttributeRef Attr)
virtual void log(raw_ostream &OS) const =0
Print an error message to an output stream.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
struct LLVMOpaqueError * LLVMErrorRef
Opaque reference to an error instance.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
static ManagedStatic< _object_error_category > error_category
void consumeError(Error Err)
Consume a Error without doing anything.
const void * LLVMErrorTypeId
Error type identifier.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
static ManagedStatic< ErrorErrorCategory > ErrorErrorCat
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
static ErrorSuccess success()
Create a success value.
LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err)
Returns the type id for the given error instance, which must be a failure value (i.e.
virtual std::error_code convertToErrorCode() const =0
Convert this error to a std::error_code.
void LLVMConsumeError(LLVMErrorRef Err)
Dispose of the given error without handling it.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVMErrorTypeId LLVMGetStringErrorTypeId()
Returns the type id for llvm StringError.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
char * LLVMGetErrorMessage(LLVMErrorRef Err)
Returns the given string's error message.
Lightweight error class with error context and mandatory checking.
This class wraps a std::error_code in a Error.
This class implements an extremely fast bulk output stream that can only output to a stream...
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
void LLVMDisposeErrorMessage(char *ErrMsg)
Dispose of the given error message.
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...