1 //===-- AddressRangeListImpl.cpp ------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "lldb/Core/AddressRangeListImpl.h" 10 11 using namespace lldb; 12 using namespace lldb_private; 13 AddressRangeListImpl()14AddressRangeListImpl::AddressRangeListImpl() : m_ranges() {} 15 16 AddressRangeListImpl & operator =(const AddressRangeListImpl & rhs)17AddressRangeListImpl::operator=(const AddressRangeListImpl &rhs) { 18 if (this == &rhs) 19 return *this; 20 m_ranges = rhs.m_ranges; 21 return *this; 22 } 23 GetSize() const24size_t AddressRangeListImpl::GetSize() const { return m_ranges.size(); } 25 Reserve(size_t capacity)26void AddressRangeListImpl::Reserve(size_t capacity) { 27 m_ranges.reserve(capacity); 28 } 29 Append(const AddressRange & sb_region)30void AddressRangeListImpl::Append(const AddressRange &sb_region) { 31 m_ranges.emplace_back(sb_region); 32 } 33 Append(const AddressRangeListImpl & list)34void AddressRangeListImpl::Append(const AddressRangeListImpl &list) { 35 Reserve(GetSize() + list.GetSize()); 36 37 for (const auto &range : list.m_ranges) 38 Append(range); 39 } 40 Clear()41void AddressRangeListImpl::Clear() { m_ranges.clear(); } 42 43 lldb_private::AddressRange GetAddressRangeAtIndex(size_t index)44AddressRangeListImpl::GetAddressRangeAtIndex(size_t index) { 45 if (index >= GetSize()) 46 return AddressRange(); 47 return m_ranges[index]; 48 } 49 ref()50AddressRanges &AddressRangeListImpl::ref() { return m_ranges; } 51