Don't check for null after calling COFFObjectFile::toSec.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 7 Oct 2014 21:03:22 +0000 (21:03 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 7 Oct 2014 21:03:22 +0000 (21:03 +0000)
It can only return null if passed a corrupted reference with a null Ref.p.
Checking for null is then an issue for asserts to check for internal
consistency, not control flow to check for invalid input.

I didn't add an assert(sec != nullptr) because toSec itself has a far more
complete assert.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219235 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/COFFObjectFile.cpp

index 6e1f683..be19847 100644 (file)
@@ -286,8 +286,6 @@ std::error_code COFFObjectFile::getSectionContents(DataRefImpl Ref,
 std::error_code COFFObjectFile::getSectionAlignment(DataRefImpl Ref,
                                                     uint64_t &Res) const {
   const coff_section *Sec = toSec(Ref);
-  if (!Sec)
-    return object_error::parse_failed;
   Res = uint64_t(1) << (((Sec->Characteristics & 0x00F00000) >> 20) - 1);
   return object_error::success;
 }