[ORC-RT] Make ExecutorAddr hashable.

This will be used in an upcoming macho_platform patch.
This commit is contained in:
Lang Hames 2022-02-08 16:10:10 +11:00
parent c840047c38
commit ea0ce326fd
2 changed files with 18 additions and 0 deletions

View File

@ -212,4 +212,15 @@ using SPSExecutorAddrRangeSequence = SPSSequence<SPSExecutorAddrRange>;
} // End namespace __orc_rt
namespace std {
// Make ExecutorAddr hashable.
template <> struct hash<__orc_rt::ExecutorAddr> {
size_t operator()(const __orc_rt::ExecutorAddr &A) const {
return hash<uint64_t>()(A.getValue());
}
};
} // namespace std
#endif // ORC_RT_EXECUTOR_ADDRESS_H

View File

@ -75,3 +75,10 @@ TEST(ExecutorAddrTest, AddrRanges) {
EXPECT_TRUE(R1.overlaps(R3));
EXPECT_TRUE(R1.overlaps(R4));
}
TEST(ExecutorAddrTest, Hashable) {
uint64_t RawAddr = 0x1234567890ABCDEF;
ExecutorAddr Addr(RawAddr);
EXPECT_EQ(std::hash<uint64_t>()(RawAddr), std::hash<ExecutorAddr>()(Addr));
}