Error setProtections(void *block, unsigned Flags) {
auto I = Allocs.find(block);
if (I == Allocs.end())
- return orcError(OrcErrorCode::RemoteMProtectAddrUnrecognized);
+ return errorCodeToError(orcError(OrcErrorCode::RemoteMProtectAddrUnrecognized));
return errorCodeToError(
sys::Memory::protectMappedMemory(I->second, Flags));
}
Error handleCreateRemoteAllocator(ResourceIdMgr::ResourceId Id) {
auto I = Allocators.find(Id);
if (I != Allocators.end())
- return orcError(OrcErrorCode::RemoteAllocatorIdAlreadyInUse);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteAllocatorIdAlreadyInUse));
DEBUG(dbgs() << " Created allocator " << Id << "\n");
Allocators[Id] = Allocator();
return Error::success();
Error handleCreateIndirectStubsOwner(ResourceIdMgr::ResourceId Id) {
auto I = IndirectStubsOwners.find(Id);
if (I != IndirectStubsOwners.end())
- return orcError(OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse));
DEBUG(dbgs() << " Create indirect stubs owner " << Id << "\n");
IndirectStubsOwners[Id] = ISBlockOwnerList();
return Error::success();
Error handleDestroyRemoteAllocator(ResourceIdMgr::ResourceId Id) {
auto I = Allocators.find(Id);
if (I == Allocators.end())
- return orcError(OrcErrorCode::RemoteAllocatorDoesNotExist);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteAllocatorDoesNotExist));
Allocators.erase(I);
DEBUG(dbgs() << " Destroyed allocator " << Id << "\n");
return Error::success();
Error handleDestroyIndirectStubsOwner(ResourceIdMgr::ResourceId Id) {
auto I = IndirectStubsOwners.find(Id);
if (I == IndirectStubsOwners.end())
- return orcError(OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist));
IndirectStubsOwners.erase(I);
return Error::success();
}
auto StubOwnerItr = IndirectStubsOwners.find(Id);
if (StubOwnerItr == IndirectStubsOwners.end())
- return orcError(OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist));
typename TargetT::IndirectStubsInfo IS;
if (auto Err =
uint64_t Size, uint32_t Align) {
auto I = Allocators.find(Id);
if (I == Allocators.end())
- return orcError(OrcErrorCode::RemoteAllocatorDoesNotExist);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteAllocatorDoesNotExist));
auto &Allocator = I->second;
void *LocalAllocAddr = nullptr;
if (auto Err = Allocator.allocate(LocalAllocAddr, Size, Align))
JITTargetAddress Addr, uint32_t Flags) {
auto I = Allocators.find(Id);
if (I == Allocators.end())
- return orcError(OrcErrorCode::RemoteAllocatorDoesNotExist);
+ return errorCodeToError(
+ orcError(OrcErrorCode::RemoteAllocatorDoesNotExist));
auto &Allocator = I->second;
void *LocalAddr = reinterpret_cast<void *>(static_cast<uintptr_t>(Addr));
DEBUG(dbgs() << " Allocator " << Id << " set permissions on " << LocalAddr
// Create an error instance representing an abandoned response.
static Error createAbandonedResponseError() {
- return orcError(OrcErrorCode::RPCResponseAbandoned);
+ return errorCodeToError(orcError(OrcErrorCode::RPCResponseAbandoned));
}
};
return Err;
if (auto Err = C.endReceiveMessage())
return Err;
- return Handler(Result);
+ return Handler(std::move(Result));
}
// Abandon this response by calling the handler with an 'abandoned response'
// This isn't a channel error so we don't want to abandon other pending
// responses, but we still need to run the user handler with an error to
// let them know the call failed.
- if (auto Err = Handler(orcError(OrcErrorCode::UnknownRPCFunction)))
+ if (auto Err = Handler(errorCodeToError(
+ orcError(OrcErrorCode::UnknownRPCFunction))))
report_fatal_error(std::move(Err));
return FnIdOrErr.takeError();
}
return I->second(C, SeqNo);
// else: No handler found. Report error to client?
- return orcError(OrcErrorCode::UnexpectedRPCCall);
+ return errorCodeToError(orcError(OrcErrorCode::UnexpectedRPCCall));
}
/// Helper for handling setter procedures - this method returns a functor that
// Unlock the pending results map to prevent recursive lock.
Lock.unlock();
abandonPendingResponses();
- return orcError(OrcErrorCode::UnexpectedRPCResponse);
+ return errorCodeToError(orcError(OrcErrorCode::UnexpectedRPCResponse));
}
}
char RPCFunctionNotSupported::ID = 0;
-Error orcError(OrcErrorCode ErrCode) {
+std::error_code orcError(OrcErrorCode ErrCode) {
typedef std::underlying_type<OrcErrorCode>::type UT;
- return errorCodeToError(
- std::error_code(static_cast<UT>(ErrCode), *OrcErrCat));
+ return std::error_code(static_cast<UT>(ErrCode), *OrcErrCat);
}
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);
+ return orcError(OrcErrorCode::UnknownRPCFunction);
}
void RPCFunctionNotSupported::log(raw_ostream &OS) const {