Fix coding style violations in 162135 and 162136.
[oota-llvm.git] / lib / DebugInfo / DWARFDebugArangeSet.cpp
index a3e2e62104c77ead51d1d071d04ad756b4edf388..2efbfd1f92fb946ae5c2a9c96c0f40ff53683e26 100644 (file)
@@ -72,6 +72,13 @@ DWARFDebugArangeSet::extract(DataExtractor data, uint32_t *offset_ptr) {
     Header.AddrSize = data.getU8(offset_ptr);
     Header.SegSize = data.getU8(offset_ptr);
 
+    // Perform basic validation of the header fields.
+    if (!data.isValidOffsetForDataOfSize(Offset, Header.Length) ||
+        (Header.AddrSize != 4 && Header.AddrSize != 8)) {
+      clear();
+      return false;
+    }
+
     // The first tuple following the header in each set begins at an offset
     // that is a multiple of the size of a single tuple (that is, twice the
     // size of an address). The header is padded, if necessary, to the
@@ -115,19 +122,22 @@ void DWARFDebugArangeSet::dump(raw_ostream &OS) const {
   const uint32_t hex_width = Header.AddrSize * 2;
   for (DescriptorConstIter pos = ArangeDescriptors.begin(),
        end = ArangeDescriptors.end(); pos != end; ++pos)
-    OS << format("[0x%*.*llx -", hex_width, hex_width, pos->Address)
-       << format(" 0x%*.*llx)\n", hex_width, hex_width, pos->getEndAddress());
+    OS << format("[0x%*.*" PRIx64 " -", hex_width, hex_width, pos->Address)
+       << format(" 0x%*.*" PRIx64 ")\n",
+                 hex_width, hex_width, pos->getEndAddress());
 }
 
 
-class DescriptorContainsAddress {
-  const uint64_t Address;
-public:
-  DescriptorContainsAddress(uint64_t address) : Address(address) {}
-  bool operator()(const DWARFDebugArangeSet::Descriptor &desc) const {
-    return Address >= desc.Address && Address < (desc.Address + desc.Length);
-  }
-};
+namespace {
+  class DescriptorContainsAddress {
+    const uint64_t Address;
+  public:
+    DescriptorContainsAddress(uint64_t address) : Address(address) {}
+    bool operator()(const DWARFDebugArangeSet::Descriptor &desc) const {
+      return Address >= desc.Address && Address < (desc.Address + desc.Length);
+    }
+  };
+}
 
 uint32_t DWARFDebugArangeSet::findAddress(uint64_t address) const {
   DescriptorConstIter end = ArangeDescriptors.end();