1*9880d681SAndroid Build Coastguard Worker //===---------------- OrcError.cpp - Error codes for ORC ------------------===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // Error codes for ORC. 11*9880d681SAndroid Build Coastguard Worker // 12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker #include "llvm/ExecutionEngine/Orc/OrcError.h" 15*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/ErrorHandling.h" 16*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/ManagedStatic.h" 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker using namespace llvm; 19*9880d681SAndroid Build Coastguard Worker using namespace llvm::orc; 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker namespace { 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker // FIXME: This class is only here to support the transition to llvm::Error. It 24*9880d681SAndroid Build Coastguard Worker // will be removed once this transition is complete. Clients should prefer to 25*9880d681SAndroid Build Coastguard Worker // deal with the Error value directly, rather than converting to error_code. 26*9880d681SAndroid Build Coastguard Worker class OrcErrorCategory : public std::error_category { 27*9880d681SAndroid Build Coastguard Worker public: name() const28*9880d681SAndroid Build Coastguard Worker const char *name() const LLVM_NOEXCEPT override { return "orc"; } 29*9880d681SAndroid Build Coastguard Worker message(int condition) const30*9880d681SAndroid Build Coastguard Worker std::string message(int condition) const override { 31*9880d681SAndroid Build Coastguard Worker switch (static_cast<OrcErrorCode>(condition)) { 32*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::RemoteAllocatorDoesNotExist: 33*9880d681SAndroid Build Coastguard Worker return "Remote allocator does not exist"; 34*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::RemoteAllocatorIdAlreadyInUse: 35*9880d681SAndroid Build Coastguard Worker return "Remote allocator Id already in use"; 36*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::RemoteMProtectAddrUnrecognized: 37*9880d681SAndroid Build Coastguard Worker return "Remote mprotect call references unallocated memory"; 38*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist: 39*9880d681SAndroid Build Coastguard Worker return "Remote indirect stubs owner does not exist"; 40*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse: 41*9880d681SAndroid Build Coastguard Worker return "Remote indirect stubs owner Id already in use"; 42*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::UnexpectedRPCCall: 43*9880d681SAndroid Build Coastguard Worker return "Unexpected RPC call"; 44*9880d681SAndroid Build Coastguard Worker case OrcErrorCode::UnexpectedRPCResponse: 45*9880d681SAndroid Build Coastguard Worker return "Unexpected RPC response"; 46*9880d681SAndroid Build Coastguard Worker } 47*9880d681SAndroid Build Coastguard Worker llvm_unreachable("Unhandled error code"); 48*9880d681SAndroid Build Coastguard Worker } 49*9880d681SAndroid Build Coastguard Worker }; 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Worker static ManagedStatic<OrcErrorCategory> OrcErrCat; 52*9880d681SAndroid Build Coastguard Worker } 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard Worker namespace llvm { 55*9880d681SAndroid Build Coastguard Worker namespace orc { 56*9880d681SAndroid Build Coastguard Worker orcError(OrcErrorCode ErrCode)57*9880d681SAndroid Build Coastguard WorkerError orcError(OrcErrorCode ErrCode) { 58*9880d681SAndroid Build Coastguard Worker typedef std::underlying_type<OrcErrorCode>::type UT; 59*9880d681SAndroid Build Coastguard Worker return errorCodeToError( 60*9880d681SAndroid Build Coastguard Worker std::error_code(static_cast<UT>(ErrCode), *OrcErrCat)); 61*9880d681SAndroid Build Coastguard Worker } 62*9880d681SAndroid Build Coastguard Worker } 63*9880d681SAndroid Build Coastguard Worker } 64