[orc-rt] Add ExecutorAddrRange::contains overload for ranges. (#163458)
Can be used to test that one address range is fully contained within another. This is an orc-rt counterpart to aa731e19045, which added the same operation to llvm::orc::ExecutorAddrRange.
This commit is contained in:
parent
0fefa56b03
commit
d098f19e0a
@ -204,6 +204,9 @@ struct ExecutorAddrRange {
|
||||
constexpr bool contains(ExecutorAddr Addr) const noexcept {
|
||||
return Start <= Addr && Addr < End;
|
||||
}
|
||||
constexpr bool contains(const ExecutorAddrRange &Other) const noexcept {
|
||||
return (Other.Start >= Start && Other.End <= End);
|
||||
}
|
||||
constexpr bool overlaps(const ExecutorAddrRange &Other) const noexcept {
|
||||
return !(Other.End <= Start || End <= Other.Start);
|
||||
}
|
||||
|
||||
@ -97,10 +97,16 @@ TEST(ExecutorAddrTest, AddrRanges) {
|
||||
EXPECT_FALSE(R1.contains(A0));
|
||||
EXPECT_FALSE(R1.contains(A2));
|
||||
|
||||
EXPECT_TRUE(R3.contains(R0)); // True for singleton range at start.
|
||||
EXPECT_TRUE(R3.contains(R1)); // True for singleton range at end.
|
||||
EXPECT_FALSE(R3.contains(R2)); // False for non-overlaping singleton range.
|
||||
EXPECT_FALSE(R3.contains(R4)); // False for overlapping, uncontained range.
|
||||
|
||||
EXPECT_FALSE(R1.overlaps(R0));
|
||||
EXPECT_FALSE(R1.overlaps(R2));
|
||||
EXPECT_TRUE(R1.overlaps(R3));
|
||||
EXPECT_TRUE(R1.overlaps(R4));
|
||||
EXPECT_TRUE(R3.overlaps(R4));
|
||||
}
|
||||
|
||||
TEST(ExecutorAddrTest, Hashable) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user