[llvm] r219235 - Don't check for null after calling COFFObjectFile::toSec.

Rafael Espindola rafael.espindola at gmail.com
Tue Oct 7 14:03:22 PDT 2014

Author: rafael
Date: Tue Oct  7 16:03:22 2014
New Revision: 219235

URL: http://llvm.org/viewvc/llvm-project?rev=219235&view=rev
Don't check for null after calling COFFObjectFile::toSec.

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.


Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=219235&r1=219234&r2=219235&view=diff
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Tue Oct  7 16:03:22 2014
@@ -286,8 +286,6 @@ std::error_code COFFObjectFile::getSecti
 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;

More information about the llvm-commits mailing list