diff --git a/include/llvm/ExecutionEngine/Orc/OrcError.h b/include/llvm/ExecutionEngine/Orc/OrcError.h index b74988cce2f..34ce2c174c4 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcError.h +++ b/include/llvm/ExecutionEngine/Orc/OrcError.h @@ -35,6 +35,18 @@ enum class OrcErrorCode : int { Error orcError(OrcErrorCode ErrCode); +class RPCFunctionNotSupported : public ErrorInfo { +public: + static char ID; + + RPCFunctionNotSupported(std::string RPCFunctionSignature); + std::error_code convertToErrorCode() const override; + void log(raw_ostream &OS) const override; + const std::string &getFunctionSignature() const; +private: + std::string RPCFunctionSignature; +}; + } // End namespace orc. } // End namespace llvm. diff --git a/include/llvm/ExecutionEngine/Orc/RPCUtils.h b/include/llvm/ExecutionEngine/Orc/RPCUtils.h index 37e2e66e5af..4be247a1cde 100644 --- a/include/llvm/ExecutionEngine/Orc/RPCUtils.h +++ b/include/llvm/ExecutionEngine/Orc/RPCUtils.h @@ -1116,7 +1116,7 @@ public: return Error::success(); // If it's invalid and we can't re-attempt negotiation, throw an error. if (!Retry) - return orcError(OrcErrorCode::UnknownRPCFunction); + return make_error(Func::getPrototype()); } // We don't have a function id for Func yet, call the remote to try to @@ -1254,7 +1254,7 @@ public: return Error::success(); // If it's invalid and we can't re-attempt negotiation, throw an error. if (!Retry) - return orcError(OrcErrorCode::UnknownRPCFunction); + return make_error(Func::getPrototype()); } // We don't have a function id for Func yet, call the remote to try to diff --git a/lib/ExecutionEngine/Orc/OrcError.cpp b/lib/ExecutionEngine/Orc/OrcError.cpp index c531fe36992..eaa75ad06a2 100644 --- a/lib/ExecutionEngine/Orc/OrcError.cpp +++ b/lib/ExecutionEngine/Orc/OrcError.cpp @@ -58,10 +58,30 @@ static ManagedStatic OrcErrCat; namespace llvm { namespace orc { +char RPCFunctionNotSupported::ID = 0; + Error orcError(OrcErrorCode ErrCode) { typedef std::underlying_type::type UT; return errorCodeToError( std::error_code(static_cast(ErrCode), *OrcErrCat)); } + +RPCFunctionNotSupported::RPCFunctionNotSupported(std::string RPCFunctionSignature) + : RPCFunctionSignature(std::move(RPCFunctionSignature)) {} + +std::error_code RPCFunctionNotSupported::convertToErrorCode() const { + typedef std::underlying_type::type UT; + return std::error_code(static_cast(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; +} + } }