Constify a few things with DotDebugLocEntry.
[oota-llvm.git] / lib / MC / MCObjectDisassembler.cpp
index ceebf0f8642dfb937510b3957f41575a383e4b1d..5851bdfdb71bac20bbedcb91314bb99c134b3b5b 100644 (file)
@@ -37,11 +37,8 @@ MCObjectDisassembler::MCObjectDisassembler(const ObjectFile &Obj,
     : Obj(Obj), Dis(Dis), MIA(MIA), MOS(0) {}
 
 uint64_t MCObjectDisassembler::getEntrypoint() {
-  error_code ec;
-  for (symbol_iterator SI = Obj.begin_symbols(), SE = Obj.end_symbols();
-       SI != SE; SI.increment(ec)) {
-    if (ec)
-      break;
+  for (symbol_iterator SI = Obj.symbol_begin(), SE = Obj.symbol_end();
+       SI != SE; ++SI) {
     StringRef Name;
     SI->getName(Name);
     if (Name == "main" || Name == "_main") {
@@ -90,13 +87,8 @@ MCModule *MCObjectDisassembler::buildModule(bool withCFG) {
 }
 
 void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
-  error_code ec;
-  for (section_iterator SI = Obj.begin_sections(),
-                        SE = Obj.end_sections();
-                        SI != SE;
-                        SI.increment(ec)) {
-    if (ec) break;
-
+  for (section_iterator SI = Obj.section_begin(), SE = Obj.section_end();
+       SI != SE; ++SI) {
     bool isText; SI->isText(isText);
     bool isData; SI->isData(isData);
     if (!isData && !isText)
@@ -135,11 +127,13 @@ void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
           Text->addInst(Inst, InstSize);
           InvalidData = 0;
         } else {
+          assert(InstSize && "getInstruction() consumed no bytes");
           if (!InvalidData) {
             Text = 0;
-            InvalidData = Module->createDataAtom(CurAddr, EndAddr);
+            InvalidData = Module->createDataAtom(CurAddr, CurAddr+InstSize - 1);
           }
-          InvalidData->addData(Contents[Index]);
+          for (uint64_t I = 0; I < InstSize; ++I)
+            InvalidData->addData(Contents[Index+I]);
         }
       }
     } else {
@@ -182,11 +176,8 @@ void MCObjectDisassembler::buildCFG(MCModule *Module) {
   AddressSetTy Splits;
   AddressSetTy Calls;
 
-  error_code ec;
-  for (symbol_iterator SI = Obj.begin_symbols(), SE = Obj.end_symbols();
-       SI != SE; SI.increment(ec)) {
-    if (ec)
-      break;
+  for (symbol_iterator SI = Obj.symbol_begin(), SE = Obj.symbol_end();
+       SI != SE; ++SI) {
     SymbolRef::Type SymType;
     SI->getType(SymType);
     if (SymType == SymbolRef::ST_Function) {
@@ -504,11 +495,8 @@ MCMachOObjectDisassembler::MCMachOObjectDisassembler(
     : MCObjectDisassembler(MOOF, Dis, MIA), MOOF(MOOF),
       VMAddrSlide(VMAddrSlide), HeaderLoadAddress(HeaderLoadAddress) {
 
-  error_code ec;
-  for (section_iterator SI = MOOF.begin_sections(), SE = MOOF.end_sections();
-       SI != SE; SI.increment(ec)) {
-    if (ec)
-      break;
+  for (section_iterator SI = MOOF.section_begin(), SE = MOOF.section_end();
+       SI != SE; ++SI) {
     StringRef Name;
     SI->getName(Name);
     // FIXME: We should use the S_ section type instead of the name.
@@ -537,10 +525,10 @@ uint64_t MCMachOObjectDisassembler::getEntrypoint() {
 
   // Look for LC_MAIN.
   {
-    uint32_t LoadCommandCount = MOOF.getHeader().NumLoadCommands;
+    uint32_t LoadCommandCount = MOOF.getHeader().ncmds;
     MachOObjectFile::LoadCommandInfo Load = MOOF.getFirstLoadCommandInfo();
     for (unsigned I = 0;; ++I) {
-      if (Load.C.Type == MachO::LC_MAIN) {
+      if (Load.C.cmd == MachO::LC_MAIN) {
         EntryFileOffset =
             ((const MachO::entry_point_command *)Load.Ptr)->entryoff;
         break;