[llvm] r292055 - [Orc][RPC] Add an RPCFunctionNotSupported error type and return it from
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 14 22:34:26 PST 2017
Author: lhames
Date: Sun Jan 15 00:34:25 2017
New Revision: 292055
URL: http://llvm.org/viewvc/llvm-project?rev=292055&view=rev
Log:
[Orc][RPC] Add an RPCFunctionNotSupported error type and return it from
negotiateFunction where appropriate.
Replacing the old ECError with a custom type allows us to attach the name of
the function that could not be negotiated, enabling better diagnostics for
negotiation failures.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcError.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h
llvm/trunk/lib/ExecutionEngine/Orc/OrcError.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcError.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcError.h?rev=292055&r1=292054&r2=292055&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcError.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/OrcError.h Sun Jan 15 00:34:25 2017
@@ -35,6 +35,18 @@ enum class OrcErrorCode : int {
Error orcError(OrcErrorCode ErrCode);
+class RPCFunctionNotSupported : public ErrorInfo<RPCFunctionNotSupported> {
+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.
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h?rev=292055&r1=292054&r2=292055&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/RPCUtils.h Sun Jan 15 00:34:25 2017
@@ -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<RPCFunctionNotSupported>(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<RPCFunctionNotSupported>(Func::getPrototype());
}
// We don't have a function id for Func yet, call the remote to try to
Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcError.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcError.cpp?rev=292055&r1=292054&r2=292055&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcError.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcError.cpp Sun Jan 15 00:34:25 2017
@@ -58,10 +58,30 @@ static ManagedStatic<OrcErrorCategory> O
namespace llvm {
namespace orc {
+char RPCFunctionNotSupported::ID = 0;
+
Error orcError(OrcErrorCode ErrCode) {
typedef std::underlying_type<OrcErrorCode>::type UT;
return errorCodeToError(
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);
+}
+
+void RPCFunctionNotSupported::log(raw_ostream &OS) const {
+ OS << "Could not negotiate RPC function '" << RPCFunctionSignature << "'";
+}
+
+const std::string &RPCFunctionNotSupported::getFunctionSignature() const {
+ return RPCFunctionSignature;
+}
+
}
}
More information about the llvm-commits
mailing list