[C++11] Introduce ObjectFile::symbols() to use range-based loops.
[oota-llvm.git] / lib / MC / MCObjectSymbolizer.cpp
index 4548a7d42510851195821c9f6dc0b5efe7d5ee0d..dc1253d6292b97a4d8d809bb42e94355db438d06 100644 (file)
@@ -153,14 +153,17 @@ tryAddingSymbolicOperand(MCInst &MI, raw_ostream &cStream,
     return false;
   uint64_t UValue = Value;
   // FIXME: map instead of looping each time?
-  for (symbol_iterator SI = Obj->symbol_begin(), SE = Obj->symbol_end();
-       SI != SE; ++SI) {
-    uint64_t SymAddr; SI->getAddress(SymAddr);
-    uint64_t SymSize; SI->getSize(SymSize);
-    StringRef SymName; SI->getName(SymName);
-    SymbolRef::Type SymType; SI->getType(SymType);
-    if (SymAddr == UnknownAddressOrSize || SymSize == UnknownAddressOrSize
-        || SymName.empty() || SymType != SymbolRef::ST_Function)
+  for (const SymbolRef &Symbol : Obj->symbols()) {
+    uint64_t SymAddr;
+    Symbol.getAddress(SymAddr);
+    uint64_t SymSize;
+    Symbol.getSize(SymSize);
+    StringRef SymName;
+    Symbol.getName(SymName);
+    SymbolRef::Type SymType;
+    Symbol.getType(SymType);
+    if (SymAddr == UnknownAddressOrSize || SymSize == UnknownAddressOrSize ||
+        SymName.empty() || SymType != SymbolRef::ST_Function)
       continue;
 
     if ( SymAddr == UValue ||
@@ -263,9 +266,7 @@ void MCObjectSymbolizer::buildRelocationByAddrMap() {
     RelSecI->isRequiredForExecution(RequiredForExec);
     if (RequiredForExec == false || Size == 0)
       continue;
-    for (relocation_iterator RI = Section.relocation_begin(),
-                             RE = Section.relocation_end();
-         RI != RE; ++RI) {
+    for (const RelocationRef &Reloc : Section.relocations()) {
       // FIXME: libObject is inconsistent regarding error handling. The
       // overwhelming majority of methods always return object_error::success,
       // and assert for simple errors.. Here, ELFObjectFile::getRelocationOffset
@@ -277,18 +278,18 @@ void MCObjectSymbolizer::buildRelocationByAddrMap() {
         if (ELFObj == 0)
           break;
         if (ELFObj->getELFFile()->getHeader()->e_type == ELF::ET_REL) {
-          RI->getOffset(Offset);
+          Reloc.getOffset(Offset);
           Offset += StartAddr;
         } else {
-          RI->getAddress(Offset);
+          Reloc.getAddress(Offset);
         }
       } else {
-        RI->getOffset(Offset);
+        Reloc.getOffset(Offset);
         Offset += StartAddr;
       }
       // At a specific address, only keep the first relocation.
       if (AddrToReloc.find(Offset) == AddrToReloc.end())
-        AddrToReloc[Offset] = *RI;
+        AddrToReloc[Offset] = Reloc;
     }
   }
 }