[DebugInfo] Remove unused functions from DWARFDebugAranges and fix code style.
[oota-llvm.git] / lib / DebugInfo / DWARFDebugAranges.h
1 //===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
12
13 #include "DWARFDebugArangeSet.h"
14 #include "llvm/ADT/DenseSet.h"
15 #include <list>
16
17 namespace llvm {
18
19 class DWARFContext;
20
21 class DWARFDebugAranges {
22 public:
23   struct Range {
24     explicit Range(uint64_t lo = -1ULL, uint64_t hi = -1ULL,
25                    uint32_t off = -1U)
26       : LoPC(lo), Length(hi-lo), Offset(off) {}
27
28     void clear() {
29       LoPC = -1ULL;
30       Length = 0;
31       Offset = -1U;
32     }
33
34     void setHiPC(uint64_t HiPC) {
35       if (HiPC == -1ULL || HiPC <= LoPC)
36         Length = 0;
37       else
38         Length = HiPC - LoPC;
39     }
40     uint64_t HiPC() const {
41       if (Length)
42         return LoPC + Length;
43       return -1ULL;
44     }
45     bool isValidRange() const { return Length > 0; }
46
47     static bool SortedOverlapCheck(const Range &curr_range,
48                                    const Range &next_range, uint32_t n) {
49       if (curr_range.Offset != next_range.Offset)
50         return false;
51       return curr_range.HiPC() + n >= next_range.LoPC;
52     }
53
54     bool contains(const Range &range) const {
55       return LoPC <= range.LoPC && range.HiPC() <= HiPC();
56     }
57
58     void dump(raw_ostream &OS) const;
59     uint64_t LoPC; // Start of address range
60     uint32_t Length; // End of address range (not including this address)
61     uint32_t Offset; // Offset of the compile unit or die
62   };
63
64   void clear() {
65     Aranges.clear();
66     ParsedCUOffsets.clear();
67   }
68   void extract(DataExtractor DebugArangesData);
69   void generate(DWARFContext *CTX);
70
71   // Use appendRange multiple times and then call sort.
72   void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
73   void sort(bool Minimize, uint32_t OverlapSize);
74
75   void dump(raw_ostream &OS) const;
76   uint32_t findAddress(uint64_t Address) const;
77
78   typedef std::vector<Range>              RangeColl;
79   typedef RangeColl::const_iterator       RangeCollIterator;
80   typedef DenseSet<uint32_t>              ParsedCUOffsetColl;
81
82 private:
83   RangeColl Aranges;
84   ParsedCUOffsetColl ParsedCUOffsets;
85 };
86
87 }
88
89 #endif