Use an "early return" idiom for the error case. NFC
authorFilipe Cabecinhas <me@filcab.net>
Wed, 29 Apr 2015 02:36:08 +0000 (02:36 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Wed, 29 Apr 2015 02:36:08 +0000 (02:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236080 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp

index f11eba51e6cac153fc4af95e29f565782680d5cd..b76b134b760b1b2c8ca9cb44470d968413b9ad7a 100644 (file)
@@ -1475,20 +1475,18 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
     case bitc::TYPE_CODE_ARRAY:     // ARRAY: [numelts, eltty]
       if (Record.size() < 2)
         return Error("Invalid record");
-      if ((ResultTy = getTypeByID(Record[1])) &&
-          ArrayType::isValidElementType(ResultTy))
-        ResultTy = ArrayType::get(ResultTy, Record[0]);
-      else
+      ResultTy = getTypeByID(Record[1]);
+      if (!ResultTy || !ArrayType::isValidElementType(ResultTy))
         return Error("Invalid type");
+      ResultTy = ArrayType::get(ResultTy, Record[0]);
       break;
     case bitc::TYPE_CODE_VECTOR:    // VECTOR: [numelts, eltty]
       if (Record.size() < 2)
         return Error("Invalid record");
-      if ((ResultTy = getTypeByID(Record[1])) &&
-          StructType::isValidElementType(ResultTy))
-        ResultTy = VectorType::get(ResultTy, Record[0]);
-      else
+      ResultTy = getTypeByID(Record[1]);
+      if (!ResultTy || !StructType::isValidElementType(ResultTy))
         return Error("Invalid type");
+      ResultTy = VectorType::get(ResultTy, Record[0]);
       break;
     }