[ORC] Add ordering to ExecutorAddrRanges.
This allows ranges to be sorted and used as map keys.
This commit is contained in:
@@ -206,6 +206,27 @@ struct ExecutorAddrRange {
|
||||
const ExecutorAddrRange &RHS) {
|
||||
return !(LHS == RHS);
|
||||
}
|
||||
friend bool operator<(const ExecutorAddrRange &LHS,
|
||||
const ExecutorAddrRange &RHS) {
|
||||
return LHS.Start < RHS.Start ||
|
||||
(LHS.Start == RHS.Start && LHS.End < RHS.End);
|
||||
}
|
||||
friend bool operator<=(const ExecutorAddrRange &LHS,
|
||||
const ExecutorAddrRange &RHS) {
|
||||
return LHS.Start < RHS.Start ||
|
||||
(LHS.Start == RHS.Start && LHS.End <= RHS.End);
|
||||
}
|
||||
friend bool operator>(const ExecutorAddrRange &LHS,
|
||||
const ExecutorAddrRange &RHS) {
|
||||
return LHS.Start > RHS.Start ||
|
||||
(LHS.Start == RHS.Start && LHS.End > RHS.End);
|
||||
}
|
||||
friend bool operator>=(const ExecutorAddrRange &LHS,
|
||||
const ExecutorAddrRange &RHS) {
|
||||
return LHS.Start > RHS.Start ||
|
||||
(LHS.Start == RHS.Start && LHS.End >= RHS.End);
|
||||
}
|
||||
|
||||
bool contains(ExecutorAddr Addr) const { return Start <= Addr && Addr < End; }
|
||||
bool overlaps(const ExecutorAddrRange &Other) {
|
||||
return !(Other.End <= Start || End <= Other.Start);
|
||||
|
||||
@@ -100,6 +100,11 @@ TEST(ExecutorAddrTest, AddrRanges) {
|
||||
EXPECT_FALSE(R1.overlaps(R2));
|
||||
EXPECT_TRUE(R1.overlaps(R3));
|
||||
EXPECT_TRUE(R1.overlaps(R4));
|
||||
|
||||
EXPECT_LE(R0, R0);
|
||||
EXPECT_LT(R0, R1);
|
||||
EXPECT_GE(R0, R0);
|
||||
EXPECT_GT(R1, R0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user