Small dyn_cast and auto cleanup.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 16 May 2014 14:22:33 +0000 (14:22 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 16 May 2014 14:22:33 +0000 (14:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208993 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp

index a1ae6baff9fc8be42b02641263152229ed6ebc7f..ea33578502b47bc659d42d2c253e58ae5681b108 100644 (file)
@@ -1963,11 +1963,11 @@ error_code BitcodeReader::ParseModule(bool Resume) {
       Type *Ty = getTypeByID(Record[0]);
       if (!Ty)
         return Error(InvalidRecord);
-      if (!Ty->isPointerTy())
+      auto *PTy = dyn_cast<PointerType>(Ty);
+      if (!PTy)
         return Error(InvalidTypeForValue);
 
-      auto *PTy = cast<PointerType>(Ty);
-      GlobalAlias *NewGA =
+      auto *NewGA =
           new GlobalAlias(PTy->getElementType(), GetDecodedLinkage(Record[2]),
                           "", nullptr, TheModule, PTy->getAddressSpace());
       // Old bitcode files didn't have visibility field.