[ORC] Allow construction of an ExecutorAddrRange from an addr and a size.

This commit is contained in:
Lang Hames 2021-09-24 13:51:36 -07:00
parent 9911af4b91
commit 37f1b7a3f3
2 changed files with 3 additions and 0 deletions

View File

@ -135,6 +135,8 @@ struct ExecutorAddrRange {
ExecutorAddrRange() = default;
ExecutorAddrRange(ExecutorAddr Start, ExecutorAddr End)
: Start(Start), End(End) {}
ExecutorAddrRange(ExecutorAddr Start, ExecutorAddrDiff Size)
: Start(Start), End(Start + Size) {}
bool empty() const { return Start == End; }
ExecutorAddrDiff size() const { return End - Start; }

View File

@ -58,6 +58,7 @@ TEST(ExecutorAddrTest, AddrRanges) {
// R4: ## -- Overlaps R1 end
EXPECT_EQ(R1, ExecutorAddrRange(A1, A2));
EXPECT_EQ(R1, ExecutorAddrRange(A1, ExecutorAddrDiff(1)));
EXPECT_NE(R1, R2);
EXPECT_TRUE(R1.contains(A1));