]> granicus.if.org Git - llvm/commitdiff
[ExecutionEngine] Don't dereference a dyn_cast result. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 16 Sep 2019 15:19:11 +0000 (15:19 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 16 Sep 2019 15:19:11 +0000 (15:19 +0000)
The static analyzer is warning about potential null dereferences of dyn_cast<> results - in these cases we can safely use cast<> directly as we know that these cases should all be the correct type, which is why its working atm and anyway cast<> will assert if they aren't.

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

lib/ExecutionEngine/ExecutionEngine.cpp

index a425c61210898ef0f357571d6cee1b749c8a0429..ee7a7cb60bc989b5e3e1d9ed9f2cf566da04cba2 100644 (file)
@@ -626,7 +626,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
       break;
     case Type::VectorTyID:
       // if the whole vector is 'undef' just reserve memory for the value.
-      auto* VTy = dyn_cast<VectorType>(C->getType());
+      auto* VTy = cast<VectorType>(C->getType());
       Type *ElemTy = VTy->getElementType();
       unsigned int elemNum = VTy->getNumElements();
       Result.AggregateVal.resize(elemNum);
@@ -925,7 +925,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
         elemNum = CDV->getNumElements();
         ElemTy = CDV->getElementType();
     } else if (CV || CAZ) {
-        VectorType* VTy = dyn_cast<VectorType>(C->getType());
+        auto* VTy = cast<VectorType>(C->getType());
         elemNum = VTy->getNumElements();
         ElemTy = VTy->getElementType();
     } else {