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 class OrcErrorCategory : public std::error_category {
25 const char *name() const LLVM_NOEXCEPT override { return "orc"; }
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";
42 llvm_unreachable("Unhandled error code");
46 static ManagedStatic<OrcErrorCategory> OrcErrCat;
52 std::error_code orcError(OrcErrorCode ErrCode) {
53 typedef std::underlying_type<OrcErrorCode>::type UT;
54 return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);