diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Core/AddressRange.cpp | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/Core/AddressRange.cpp')
-rw-r--r-- | source/Core/AddressRange.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source/Core/AddressRange.cpp b/source/Core/AddressRange.cpp index 1afe4fa223db..71eec3c19607 100644 --- a/source/Core/AddressRange.cpp +++ b/source/Core/AddressRange.cpp @@ -1,9 +1,8 @@ //===-- AddressRange.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -123,6 +122,24 @@ bool AddressRange::ContainsLoadAddress(addr_t load_addr, Target *target) const { return false; } +bool AddressRange::Extend(const AddressRange &rhs_range) { + addr_t lhs_end_addr = GetBaseAddress().GetFileAddress() + GetByteSize(); + addr_t rhs_base_addr = rhs_range.GetBaseAddress().GetFileAddress(); + + if (!ContainsFileAddress(rhs_range.GetBaseAddress()) && + lhs_end_addr != rhs_base_addr) + // The ranges don't intersect at all on the right side of this range. + return false; + + addr_t rhs_end_addr = rhs_base_addr + rhs_range.GetByteSize(); + if (lhs_end_addr >= rhs_end_addr) + // The rhs range totally overlaps this one, nothing to add. + return false; + + m_byte_size += rhs_end_addr - lhs_end_addr; + return true; +} + void AddressRange::Clear() { m_base_addr.Clear(); m_byte_size = 0; |