mirror of
https://github.com/RPCS3/llvm.git
synced 2025-03-06 17:47:37 +00:00
[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:
parent
24828a324b
commit
e460ede847
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user