aboutsummaryrefslogtreecommitdiff
path: root/orc-rt
diff options
context:
space:
mode:
Diffstat (limited to 'orc-rt')
-rw-r--r--orc-rt/include/orc-rt/ExecutorAddress.h3
-rw-r--r--orc-rt/unittests/ExecutorAddressTest.cpp6
2 files changed, 9 insertions, 0 deletions
diff --git a/orc-rt/include/orc-rt/ExecutorAddress.h b/orc-rt/include/orc-rt/ExecutorAddress.h
index cc7bbf5..6ec583f 100644
--- a/orc-rt/include/orc-rt/ExecutorAddress.h
+++ b/orc-rt/include/orc-rt/ExecutorAddress.h
@@ -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);
}
diff --git a/orc-rt/unittests/ExecutorAddressTest.cpp b/orc-rt/unittests/ExecutorAddressTest.cpp
index 98074a7..2e04901 100644
--- a/orc-rt/unittests/ExecutorAddressTest.cpp
+++ b/orc-rt/unittests/ExecutorAddressTest.cpp
@@ -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) {