[llvm] r372529 - Verifier - silence static analyzer dyn_cast<VectorType> null dereference warnings. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 22 14:01:23 PDT 2019


Author: rksimon
Date: Sun Sep 22 14:01:23 2019
New Revision: 372529

URL: http://llvm.org/viewvc/llvm-project?rev=372529&view=rev
Log:
Verifier - silence static analyzer dyn_cast<VectorType> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should be able to use cast<VectorType> directly and if not assert will fire for us.

Modified:
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=372529&r1=372528&r2=372529&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sun Sep 22 14:01:23 2019
@@ -2722,8 +2722,8 @@ void Verifier::visitPtrToIntInst(PtrToIn
          &I);
 
   if (SrcTy->isVectorTy()) {
-    VectorType *VSrc = dyn_cast<VectorType>(SrcTy);
-    VectorType *VDest = dyn_cast<VectorType>(DestTy);
+    VectorType *VSrc = cast<VectorType>(SrcTy);
+    VectorType *VDest = cast<VectorType>(DestTy);
     Assert(VSrc->getNumElements() == VDest->getNumElements(),
            "PtrToInt Vector width mismatch", &I);
   }
@@ -2747,8 +2747,8 @@ void Verifier::visitIntToPtrInst(IntToPt
   Assert(SrcTy->isVectorTy() == DestTy->isVectorTy(), "IntToPtr type mismatch",
          &I);
   if (SrcTy->isVectorTy()) {
-    VectorType *VSrc = dyn_cast<VectorType>(SrcTy);
-    VectorType *VDest = dyn_cast<VectorType>(DestTy);
+    VectorType *VSrc = cast<VectorType>(SrcTy);
+    VectorType *VDest = cast<VectorType>(DestTy);
     Assert(VSrc->getNumElements() == VDest->getNumElements(),
            "IntToPtr Vector width mismatch", &I);
   }




More information about the llvm-commits mailing list