[llvm] r375426 - IndVarSimplify - silence static analyzer dyn_cast<> null dereference warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 10:15:05 PDT 2019


Author: rksimon
Date: Mon Oct 21 10:15:05 2019
New Revision: 375426

URL: http://llvm.org/viewvc/llvm-project?rev=375426&view=rev
Log:
IndVarSimplify - silence static analyzer dyn_cast<> null dereference warning. NFCI.

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

Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=375426&r1=375425&r2=375426&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Oct 21 10:15:05 2019
@@ -2268,8 +2268,8 @@ static PHINode *FindLoopCounter(Loop *L,
     if (BECount->getType()->isPointerTy() && !Phi->getType()->isPointerTy())
       continue;
 
-    const auto *AR = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(Phi));
-    
+    const auto *AR = cast<SCEVAddRecExpr>(SE->getSCEV(Phi));
+
     // AR may be a pointer type, while BECount is an integer type.
     // AR may be wider than BECount. With eq/ne tests overflow is immaterial.
     // AR may not be a narrower type, or we may never exit.




More information about the llvm-commits mailing list