forked from OSchip/llvm-project
[ORC][ORC-RT] Make WrapperFunctionCall::Create support void functions.
Serialized calls to void-wrapper-functions should have zero bytes of argument data, but accessing ArgData[0] may (and will, in the case of SmallVector) fail if the argument data buffer is empty. This commit fixes the issue by adding a check for empty argument buffers.
This commit is contained in:
parent
cf07277fb4
commit
0e43f3b04d
|
@ -66,6 +66,10 @@ TEST(WrapperFunctionUtilsTest, WrapperFunctionResultFromOutOfBandError) {
|
|||
EXPECT_TRUE(strcmp(R.getOutOfBandError(), TestString) == 0);
|
||||
}
|
||||
|
||||
TEST(WrapperFunctionUtilsTest, WrapperFunctionCCallCreateEmpty) {
|
||||
EXPECT_TRUE(!!WrapperFunctionCall::Create<SPSArgList<>>(ExecutorAddr()));
|
||||
}
|
||||
|
||||
static void voidNoop() {}
|
||||
|
||||
static __orc_rt_CWrapperFunctionResult voidNoopWrapper(const char *ArgData,
|
||||
|
|
|
@ -408,7 +408,8 @@ public:
|
|||
const ArgTs &...Args) {
|
||||
ArgDataBufferType ArgData;
|
||||
ArgData.resize(SPSSerializer::size(Args...));
|
||||
SPSOutputBuffer OB(&ArgData[0], ArgData.size());
|
||||
SPSOutputBuffer OB(ArgData.empty() ? nullptr : ArgData.data(),
|
||||
ArgData.size());
|
||||
if (SPSSerializer::serialize(OB, Args...))
|
||||
return WrapperFunctionCall(FnAddr, std::move(ArgData));
|
||||
return make_error<StringError>("Cannot serialize arguments for "
|
||||
|
|
|
@ -636,7 +636,8 @@ public:
|
|||
const ArgTs &...Args) {
|
||||
ArgDataBufferType ArgData;
|
||||
ArgData.resize(SPSSerializer::size(Args...));
|
||||
SPSOutputBuffer OB(&ArgData[0], ArgData.size());
|
||||
SPSOutputBuffer OB(ArgData.empty() ? nullptr : ArgData.data(),
|
||||
ArgData.size());
|
||||
if (SPSSerializer::serialize(OB, Args...))
|
||||
return WrapperFunctionCall(FnAddr, std::move(ArgData));
|
||||
return make_error<StringError>("Cannot serialize arguments for "
|
||||
|
|
|
@ -58,6 +58,11 @@ TEST(WrapperFunctionUtilsTest, WrapperFunctionResultFromOutOfBandError) {
|
|||
EXPECT_TRUE(strcmp(R.getOutOfBandError(), TestString) == 0);
|
||||
}
|
||||
|
||||
TEST(WrapperFunctionUtilsTest, WrapperFunctionCCallCreateEmpty) {
|
||||
EXPECT_THAT_EXPECTED(
|
||||
WrapperFunctionCall::Create<SPSArgList<>>(ExecutorAddr()), Succeeded());
|
||||
}
|
||||
|
||||
static void voidNoop() {}
|
||||
|
||||
class AddClass {
|
||||
|
|
Loading…
Reference in New Issue