Remove object_error::success and use std::error_code() instead

make_error_code(object_error) is slow because object::object_category()
uses a ManagedStatic variable. But the real problem is that the function is
called too frequently. This patch uses std::error_code() instead of
object_error::success. In most cases, we return "success", so this patch
reduces number of function calls to that function.

http://reviews.llvm.org/D10333

llvm-svn: 239409
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 075d959..d02ca48 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -221,7 +221,7 @@
     Sections.push_back(Sec);
   }
   IsPageZeroSegment |= StringRef("__PAGEZERO").equals(S.segname);
-  return object_error::success;
+  return std::error_code();
 }
 
 MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
@@ -336,7 +336,7 @@
     report_fatal_error(
         "Symbol name entry points before beginning or past end of file.");
   Res = StringRef(Start);
-  return object_error::success;
+  return std::error_code();
 }
 
 unsigned MachOObjectFile::getSectionType(SectionRef Sec) const {
@@ -366,7 +366,7 @@
     return object_error::parse_failed;
   const char *Start = &StringTable.data()[NValue];
   Res = StringRef(Start);
-  return object_error::success;
+  return std::error_code();
 }
 
 std::error_code MachOObjectFile::getSymbolAddress(DataRefImpl Symb,
@@ -386,7 +386,7 @@
     else
       Res = Entry.n_value;
   }
-  return object_error::success;
+  return std::error_code();
 }
 
 uint32_t MachOObjectFile::getSymbolAlignment(DataRefImpl DRI) const {
@@ -417,7 +417,7 @@
   // If this is a STAB debugging symbol, we can do nothing more.
   if (n_type & MachO::N_STAB) {
     Res = SymbolRef::ST_Debug;
-    return object_error::success;
+    return std::error_code();
   }
 
   switch (n_type & MachO::N_TYPE) {
@@ -428,7 +428,7 @@
       Res = SymbolRef::ST_Function;
       break;
   }
-  return object_error::success;
+  return std::error_code();
 }
 
 uint32_t MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const {
@@ -488,7 +488,7 @@
     Res = section_iterator(SectionRef(DRI, this));
   }
 
-  return object_error::success;
+  return std::error_code();
 }
 
 void MachOObjectFile::moveSectionNext(DataRefImpl &Sec) const {
@@ -499,7 +499,7 @@
                                                 StringRef &Result) const {
   ArrayRef<char> Raw = getSectionRawName(Sec);
   Result = parseSegmentOrSectionName(Raw.data());
-  return object_error::success;
+  return std::error_code();
 }
 
 uint64_t MachOObjectFile::getSectionAddress(DataRefImpl Sec) const {
@@ -530,7 +530,7 @@
   }
 
   Res = this->getData().substr(Offset, Size);
-  return object_error::success;
+  return std::error_code();
 }
 
 uint64_t MachOObjectFile::getSectionAlignment(DataRefImpl Sec) const {
@@ -625,7 +625,7 @@
   Sec.d.a = Rel.d.a;
   uint64_t SecAddress = getSectionAddress(Sec);
   Res = SecAddress + Offset;
-  return object_error::success;
+  return std::error_code();
 }
 
 std::error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
@@ -634,7 +634,7 @@
          "Only implemented for MH_OBJECT");
   MachO::any_relocation_info RE = getRelocation(Rel);
   Res = getAnyRelocationAddress(RE);
-  return object_error::success;
+  return std::error_code();
 }
 
 symbol_iterator
@@ -667,7 +667,7 @@
                                                    uint64_t &Res) const {
   MachO::any_relocation_info RE = getRelocation(Rel);
   Res = getAnyRelocationType(RE);
-  return object_error::success;
+  return std::error_code();
 }
 
 std::error_code
@@ -779,7 +779,7 @@
       break;
   }
   Result.append(res.begin(), res.end());
-  return object_error::success;
+  return std::error_code();
 }
 
 std::error_code MachOObjectFile::getRelocationHidden(DataRefImpl Rel,
@@ -807,7 +807,7 @@
     }
   }
 
-  return object_error::success;
+  return std::error_code();
 }
 
 uint8_t MachOObjectFile::getRelocationLength(DataRefImpl Rel) const {
@@ -990,7 +990,7 @@
   }
 
   Res = LibrariesShortNames[Index];
-  return object_error::success;
+  return std::error_code();
 }
 
 basic_symbol_iterator MachOObjectFile::symbol_begin_impl() const {