12#include <system_error>
18 enum class ErrorErrorCode :
int {
27 class ErrorErrorCategory :
public std::error_category {
29 const char *
name()
const noexcept
override {
return "Error"; }
31 std::string message(
int condition)
const override {
32 switch (
static_cast<ErrorErrorCode
>(condition)) {
33 case ErrorErrorCode::MultipleErrors:
34 return "Multiple errors";
35 case ErrorErrorCode::InconvertibleError:
36 return "Inconvertible error value. An error has occurred that could "
37 "not be converted to a known std::error_code. Please file a "
39 case ErrorErrorCode::FileError:
40 return "A file error occurred.";
49 static ErrorErrorCategory ErrorErrorCat;
55void ErrorInfoBase::anchor() {}
56char ErrorInfoBase::ID = 0;
58void ECError::anchor() {}
75 return std::error_code(
static_cast<int>(ErrorErrorCode::MultipleErrors),
80 return std::error_code(
static_cast<int>(ErrorErrorCode::InconvertibleError),
85 std::error_code NestedEC = Err->convertToErrorCode();
87 return std::error_code(
static_cast<int>(ErrorErrorCode::FileError),
108#if LLVM_ENABLE_ABI_BREAKING_CHECKS
109void Error::fatalUncheckedError()
const {
110 dbgs() <<
"Program aborted due to an unhandled Error:\n";
115 dbgs() <<
"Error value was Success. (Note: Success values must still be "
116 "checked prior to being destroyed).\n";
124StringError::StringError(
const Twine &S, std::error_code EC)
137std::error_code StringError::convertToErrorCode()
const {
142 return make_error<StringError>(Msg, EC);
146 assert(Err &&
"report_fatal_error called with success value");
158 return reinterpret_cast<ErrorInfoBase *
>(Err)->dynamicClassID();
165 char *ErrMsg =
new char[Tmp.size() + 1];
166 memcpy(ErrMsg, Tmp.data(), Tmp.size());
167 ErrMsg[Tmp.size()] =
'\0';
174 return reinterpret_cast<void *
>(&StringError::ID);
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static LLVMTargetMachineRef wrap(const TargetMachine *P)
static const char * toString(MIToken::TokenKind TokenKind)
OwningBinary< ObjectFile > * unwrap(LLVMObjectFileRef OF)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ErrorErrorCategory & getErrorErrorCat()
This class wraps a std::error_code in a Error.
Base class for error info classes.
virtual std::error_code convertToErrorCode() const =0
Convert this error to a std::error_code.
virtual void log(raw_ostream &OS) const =0
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
This class wraps a filename and another Error.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
StringError(std::error_code EC, const Twine &S=Twine())
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
char * LLVMGetErrorMessage(LLVMErrorRef Err)
Returns the given string's error message.
LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err)
Returns the type id for the given error instance, which must be a failure value (i....
LLVMErrorTypeId LLVMGetStringErrorTypeId(void)
Returns the type id for llvm StringError.
void LLVMDisposeErrorMessage(char *ErrMsg)
Dispose of the given error message.
const void * LLVMErrorTypeId
Error type identifier.
struct LLVMOpaqueError * LLVMErrorRef
Opaque reference to an error instance.
LLVMErrorRef LLVMCreateStringError(const char *ErrMsg)
Create a StringError.
void LLVMConsumeError(LLVMErrorRef Err)
Dispose of the given error without handling it.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const CustomOperand< const MCSubtargetInfo & > Msg[]
This is an optimization pass for GlobalISel generic memory operations.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
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.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
void consumeError(Error Err)
Consume a Error without doing anything.