1 //===---------------- 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 18 using namespace llvm; 19 using namespace llvm::orc; 20 21 namespace { 22 23 class OrcErrorCategory : public std::error_category { 24 public: 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 46 static ManagedStatic<OrcErrorCategory> OrcErrCat; 47 } 48 49 namespace llvm { 50 namespace orc { 51 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); 55 } 56 } 57 } 58