Silencing an "enumeral and non-enumeral type in conditional expression" warning;...
[oota-llvm.git] / lib / DebugInfo / DWARFDebugRangeList.cpp
index fa15bb0ee55dcc14f5e5cddda90dd9d31f774c81..07b23b32d1f33ef697abe5119a2d0de84fdb781a 100644 (file)
@@ -37,10 +37,7 @@ bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
       clear();
       return false;
     }
-    // The end of any given range list is marked by an end of list entry,
-    // which consists of a 0 for the beginning address offset
-    // and a 0 for the ending address offset.
-    if (entry.StartAddress == 0 && entry.EndAddress == 0)
+    if (entry.isEndOfListEntry())
       break;
     Entries.push_back(entry);
   }
@@ -48,12 +45,25 @@ bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
 }
 
 void DWARFDebugRangeList::dump(raw_ostream &OS) const {
-  for (int i = 0, n = Entries.size(); i != n; ++i) {
+  for (const RangeListEntry &RLE : Entries) {
     const char *format_str = (AddressSize == 4
                               ? "%08x %08"  PRIx64 " %08"  PRIx64 "\n"
                               : "%08x %016" PRIx64 " %016" PRIx64 "\n");
-    OS << format(format_str, Offset, Entries[i].StartAddress,
-                                     Entries[i].EndAddress);
+    OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress);
   }
   OS << format("%08x <End of list>\n", Offset);
 }
+
+DWARFAddressRangesVector
+DWARFDebugRangeList::getAbsoluteRanges(uint64_t BaseAddress) const {
+  DWARFAddressRangesVector Res;
+  for (const RangeListEntry &RLE : Entries) {
+    if (RLE.isBaseAddressSelectionEntry(AddressSize)) {
+      BaseAddress = RLE.EndAddress;
+    } else {
+      Res.push_back(std::make_pair(BaseAddress + RLE.StartAddress,
+                                   BaseAddress + RLE.EndAddress));
+    }
+  }
+  return Res;
+}