[Support] Modify LockFileManager::waitForUnlock() to return info about how the lock...
[oota-llvm.git] / lib / MC / MCObjectDisassembler.cpp
index 85de4111b7f8abd9f8a8a55d5ea659bd8b6ff390..146da6d1ed3f346ae49b33e8b9580f41782d9f0a 100644 (file)
@@ -37,13 +37,12 @@ MCObjectDisassembler::MCObjectDisassembler(const ObjectFile &Obj,
     : Obj(Obj), Dis(Dis), MIA(MIA), MOS(0) {}
 
 uint64_t MCObjectDisassembler::getEntrypoint() {
-  for (symbol_iterator SI = Obj.begin_symbols(), SE = Obj.end_symbols();
-       SI != SE; ++SI) {
+  for (const SymbolRef &Symbol : Obj.symbols()) {
     StringRef Name;
-    SI->getName(Name);
+    Symbol.getName(Name);
     if (Name == "main" || Name == "_main") {
       uint64_t Entrypoint;
-      SI->getAddress(Entrypoint);
+      Symbol.getAddress(Entrypoint);
       return getEffectiveLoadAddr(Entrypoint);
     }
   }
@@ -87,20 +86,24 @@ MCModule *MCObjectDisassembler::buildModule(bool withCFG) {
 }
 
 void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
-  for (section_iterator SI = Obj.begin_sections(), SE = Obj.end_sections();
-       SI != SE; ++SI) {
-    bool isText; SI->isText(isText);
-    bool isData; SI->isData(isData);
+  for (const SectionRef &Section : Obj.sections()) {
+    bool isText;
+    Section.isText(isText);
+    bool isData;
+    Section.isData(isData);
     if (!isData && !isText)
       continue;
 
-    uint64_t StartAddr; SI->getAddress(StartAddr);
-    uint64_t SecSize; SI->getSize(SecSize);
+    uint64_t StartAddr;
+    Section.getAddress(StartAddr);
+    uint64_t SecSize;
+    Section.getSize(SecSize);
     if (StartAddr == UnknownAddressOrSize || SecSize == UnknownAddressOrSize)
       continue;
     StartAddr = getEffectiveLoadAddr(StartAddr);
 
-    StringRef Contents; SI->getContents(Contents);
+    StringRef Contents;
+    Section.getContents(Contents);
     StringRefMemoryObject memoryObject(Contents, StartAddr);
 
     // We don't care about things like non-file-backed sections yet.
@@ -108,7 +111,8 @@ void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
       continue;
     uint64_t EndAddr = StartAddr + SecSize - 1;
 
-    StringRef SecName; SI->getName(SecName);
+    StringRef SecName;
+    Section.getName(SecName);
 
     if (isText) {
       MCTextAtom *Text = 0;
@@ -176,13 +180,12 @@ void MCObjectDisassembler::buildCFG(MCModule *Module) {
   AddressSetTy Splits;
   AddressSetTy Calls;
 
-  for (symbol_iterator SI = Obj.begin_symbols(), SE = Obj.end_symbols();
-       SI != SE; ++SI) {
+  for (const SymbolRef &Symbol : Obj.symbols()) {
     SymbolRef::Type SymType;
-    SI->getType(SymType);
+    Symbol.getType(SymType);
     if (SymType == SymbolRef::ST_Function) {
       uint64_t SymAddr;
-      SI->getAddress(SymAddr);
+      Symbol.getAddress(SymAddr);
       SymAddr = getEffectiveLoadAddr(SymAddr);
       Calls.push_back(SymAddr);
       Splits.push_back(SymAddr);
@@ -495,17 +498,16 @@ MCMachOObjectDisassembler::MCMachOObjectDisassembler(
     : MCObjectDisassembler(MOOF, Dis, MIA), MOOF(MOOF),
       VMAddrSlide(VMAddrSlide), HeaderLoadAddress(HeaderLoadAddress) {
 
-  for (section_iterator SI = MOOF.begin_sections(), SE = MOOF.end_sections();
-       SI != SE; ++SI) {
+  for (const SectionRef &Section : MOOF.sections()) {
     StringRef Name;
-    SI->getName(Name);
+    Section.getName(Name);
     // FIXME: We should use the S_ section type instead of the name.
     if (Name == "__mod_init_func") {
       DEBUG(dbgs() << "Found __mod_init_func section!\n");
-      SI->getContents(ModInitContents);
+      Section.getContents(ModInitContents);
     } else if (Name == "__mod_exit_func") {
       DEBUG(dbgs() << "Found __mod_exit_func section!\n");
-      SI->getContents(ModExitContents);
+      Section.getContents(ModExitContents);
     }
   }
 }