blob: 37b49903ba7e063ed113762effa54ed0979ebf2d [file] [log] [blame]
Lang Hames4026f902016-01-11 00:34:13 +00001//===---------------- OrcError.cpp - Error codes for ORC ------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Error codes for ORC.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/ExecutionEngine/Orc/OrcError.h"
15#include "llvm/Support/ErrorHandling.h"
16#include "llvm/Support/ManagedStatic.h"
17
18using namespace llvm;
19using namespace llvm::orc;
20
21namespace {
22
23class OrcErrorCategory : public std::error_category {
24public:
25 const char *name() const LLVM_NOEXCEPT override { return "orc"; }
26
27 std::string message(int condition) const override {
28 switch (static_cast<OrcErrorCode>(condition)) {
29 case OrcErrorCode::RemoteAllocatorDoesNotExist:
30 return "Remote allocator does not exist";
31 case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
32 return "Remote allocator Id already in use";
33 case OrcErrorCode::RemoteMProtectAddrUnrecognized:
34 return "Remote mprotect call references unallocated memory";
35 case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
36 return "Remote indirect stubs owner does not exist";
37 case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
38 return "Remote indirect stubs owner Id already in use";
39 case OrcErrorCode::UnexpectedRPCCall:
40 return "Unexpected RPC call";
Lang Hames3fde6522016-04-18 19:55:43 +000041 case OrcErrorCode::UnexpectedRPCResponse:
42 return "Unexpected RPC response";
Lang Hames4026f902016-01-11 00:34:13 +000043 }
44 llvm_unreachable("Unhandled error code");
45 }
46};
47
48static ManagedStatic<OrcErrorCategory> OrcErrCat;
49}
50
51namespace llvm {
52namespace orc {
53
Lang Hamesef5a0ee2016-04-25 19:56:45 +000054Error orcError(OrcErrorCode ErrCode) {
Lang Hames4026f902016-01-11 00:34:13 +000055 typedef std::underlying_type<OrcErrorCode>::type UT;
Lang Hamesef5a0ee2016-04-25 19:56:45 +000056 return errorCodeToError(std::error_code(static_cast<UT>(ErrCode),
57 *OrcErrCat));
Lang Hames4026f902016-01-11 00:34:13 +000058}
59}
60}