2016-01-11 08:34:13 +08:00
|
|
|
//===---------------- OrcError.cpp - Error codes for ORC ------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Error codes for ORC.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ExecutionEngine/Orc/OrcError.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::orc;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2016-05-25 04:13:46 +08:00
|
|
|
// FIXME: This class is only here to support the transition to llvm::Error. It
|
|
|
|
// will be removed once this transition is complete. Clients should prefer to
|
|
|
|
// deal with the Error value directly, rather than converting to error_code.
|
2016-01-11 08:34:13 +08:00
|
|
|
class OrcErrorCategory : public std::error_category {
|
|
|
|
public:
|
2016-10-20 07:52:38 +08:00
|
|
|
const char *name() const noexcept override { return "orc"; }
|
2016-01-11 08:34:13 +08:00
|
|
|
|
|
|
|
std::string message(int condition) const override {
|
|
|
|
switch (static_cast<OrcErrorCode>(condition)) {
|
|
|
|
case OrcErrorCode::RemoteAllocatorDoesNotExist:
|
|
|
|
return "Remote allocator does not exist";
|
|
|
|
case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
|
|
|
|
return "Remote allocator Id already in use";
|
|
|
|
case OrcErrorCode::RemoteMProtectAddrUnrecognized:
|
|
|
|
return "Remote mprotect call references unallocated memory";
|
|
|
|
case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
|
|
|
|
return "Remote indirect stubs owner does not exist";
|
|
|
|
case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
|
|
|
|
return "Remote indirect stubs owner Id already in use";
|
2016-12-26 05:55:05 +08:00
|
|
|
case OrcErrorCode::RPCResponseAbandoned:
|
|
|
|
return "RPC response abandoned";
|
2016-01-11 08:34:13 +08:00
|
|
|
case OrcErrorCode::UnexpectedRPCCall:
|
|
|
|
return "Unexpected RPC call";
|
2016-04-19 03:55:43 +08:00
|
|
|
case OrcErrorCode::UnexpectedRPCResponse:
|
|
|
|
return "Unexpected RPC response";
|
2016-11-12 05:42:09 +08:00
|
|
|
case OrcErrorCode::UnknownRPCFunction:
|
|
|
|
return "Unknown RPC function";
|
2016-01-11 08:34:13 +08:00
|
|
|
}
|
|
|
|
llvm_unreachable("Unhandled error code");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static ManagedStatic<OrcErrorCategory> OrcErrCat;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace orc {
|
|
|
|
|
2017-01-15 14:34:25 +08:00
|
|
|
char RPCFunctionNotSupported::ID = 0;
|
|
|
|
|
2016-04-26 03:56:45 +08:00
|
|
|
Error orcError(OrcErrorCode ErrCode) {
|
2016-01-11 08:34:13 +08:00
|
|
|
typedef std::underlying_type<OrcErrorCode>::type UT;
|
2016-04-26 05:21:20 +08:00
|
|
|
return errorCodeToError(
|
|
|
|
std::error_code(static_cast<UT>(ErrCode), *OrcErrCat));
|
2016-01-11 08:34:13 +08:00
|
|
|
}
|
2017-01-15 14:34:25 +08:00
|
|
|
|
|
|
|
RPCFunctionNotSupported::RPCFunctionNotSupported(std::string RPCFunctionSignature)
|
|
|
|
: RPCFunctionSignature(std::move(RPCFunctionSignature)) {}
|
|
|
|
|
|
|
|
std::error_code RPCFunctionNotSupported::convertToErrorCode() const {
|
|
|
|
typedef std::underlying_type<OrcErrorCode>::type UT;
|
|
|
|
return std::error_code(static_cast<UT>(OrcErrorCode::UnknownRPCFunction),
|
|
|
|
*OrcErrCat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RPCFunctionNotSupported::log(raw_ostream &OS) const {
|
|
|
|
OS << "Could not negotiate RPC function '" << RPCFunctionSignature << "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &RPCFunctionNotSupported::getFunctionSignature() const {
|
|
|
|
return RPCFunctionSignature;
|
|
|
|
}
|
|
|
|
|
2016-01-11 08:34:13 +08:00
|
|
|
}
|
|
|
|
}
|