blob: e95115ec6fedde288af22b380ff7fa013b45d6c8 [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";
41 }
42 llvm_unreachable("Unhandled error code");
43 }
44};
45
46static ManagedStatic<OrcErrorCategory> OrcErrCat;
47}
48
49namespace llvm {
50namespace orc {
51
52std::error_code orcError(OrcErrorCode ErrCode) {
53 typedef std::underlying_type<OrcErrorCode>::type UT;
54 return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);
55}
56}
57}