[Orc] Fix bool serialization for RawByteChannels.

The bool type may be larger than the char type, so assuming we can cast from
bool to char and write a byte out to the stream is unsafe.

Hopefully this will get RPCUtilsTest.ReturnExpectedFailure passing on the bots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300174 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames 2017-04-13 05:23:50 +00:00
parent 24828a324b
commit e460ede847

View File

@ -121,11 +121,19 @@ class SerializationTraits<ChannelT, bool, bool,
RawByteChannel, ChannelT>::value>::type> {
public:
static Error serialize(ChannelT &C, bool V) {
return C.appendBytes(reinterpret_cast<const char *>(&V), 1);
uint8_t Tmp = V ? 1 : 0;
if (auto Err =
C.appendBytes(reinterpret_cast<const char *>(&Tmp), 1))
return Err;
return Error::success();
}
static Error deserialize(ChannelT &C, bool &V) {
return C.readBytes(reinterpret_cast<char *>(&V), 1);
uint8_t Tmp = 0;
if (auto Err = C.readBytes(reinterpret_cast<char *>(&Tmp), 1))
return Err;
V = Tmp != 0;
return Error::success();
}
};