1 //===- Range.cpp ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/GSYM/Range.h"
18 void AddressRanges::insert(AddressRange Range
) {
19 if (Range
.size() == 0)
22 auto It
= llvm::upper_bound(Ranges
, Range
);
24 while (It2
!= Ranges
.end() && It2
->Start
< Range
.End
)
27 Range
.End
= std::max(Range
.End
, It2
[-1].End
);
28 It
= Ranges
.erase(It
, It2
);
30 if (It
!= Ranges
.begin() && Range
.Start
< It
[-1].End
)
31 It
[-1].End
= std::max(It
[-1].End
, Range
.End
);
33 Ranges
.insert(It
, Range
);
36 bool AddressRanges::contains(uint64_t Addr
) const {
37 auto It
= std::partition_point(
38 Ranges
.begin(), Ranges
.end(),
39 [=](const AddressRange
&R
) { return R
.Start
<= Addr
; });
40 return It
!= Ranges
.begin() && Addr
< It
[-1].End
;
43 raw_ostream
&llvm::gsym::operator<<(raw_ostream
&OS
, const AddressRange
&R
) {
44 return OS
<< '[' << HEX64(R
.Start
) << " - " << HEX64(R
.End
) << ")";
47 raw_ostream
&llvm::gsym::operator<<(raw_ostream
&OS
, const AddressRanges
&AR
) {
48 size_t Size
= AR
.size();
49 for (size_t I
= 0; I
< Size
; ++I
) {