1 //===---------------- OrcError.cpp - Error codes for ORC ------------------===//
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 // Error codes for ORC.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/ExecutionEngine/Orc/OrcError.h"
15 #include "llvm/Support/ErrorHandling.h"
16 #include "llvm/Support/ManagedStatic.h"
19 using namespace llvm::orc;
23 // FIXME: This class is only here to support the transition to llvm::Error. It
24 // will be removed once this transition is complete. Clients should prefer to
25 // deal with the Error value directly, rather than converting to error_code.
26 class OrcErrorCategory : public std::error_category {
28 const char *name() const noexcept override { return "orc"; }
30 std::string message(int condition) const override {
31 switch (static_cast<OrcErrorCode>(condition)) {
32 case OrcErrorCode::RemoteAllocatorDoesNotExist:
33 return "Remote allocator does not exist";
34 case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
35 return "Remote allocator Id already in use";
36 case OrcErrorCode::RemoteMProtectAddrUnrecognized:
37 return "Remote mprotect call references unallocated memory";
38 case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
39 return "Remote indirect stubs owner does not exist";
40 case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
41 return "Remote indirect stubs owner Id already in use";
42 case OrcErrorCode::RPCResponseAbandoned:
43 return "RPC response abandoned";
44 case OrcErrorCode::UnexpectedRPCCall:
45 return "Unexpected RPC call";
46 case OrcErrorCode::UnexpectedRPCResponse:
47 return "Unexpected RPC response";
48 case OrcErrorCode::UnknownRPCFunction:
49 return "Unknown RPC function";
51 llvm_unreachable("Unhandled error code");
55 static ManagedStatic<OrcErrorCategory> OrcErrCat;
61 Error orcError(OrcErrorCode ErrCode) {
62 typedef std::underlying_type<OrcErrorCode>::type UT;
63 return errorCodeToError(
64 std::error_code(static_cast<UT>(ErrCode), *OrcErrCat));