[llvm] r372993 - ConstantFold - silence static analyzer dyn_cast<ExtractValueInst> null dereference warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 09:30:36 PDT 2019


Author: rksimon
Date: Thu Sep 26 09:30:36 2019
New Revision: 372993

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

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

Modified:
    llvm/trunk/lib/Analysis/ConstantFolding.cpp

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=372993&r1=372992&r2=372993&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu Sep 26 09:30:36 2019
@@ -1056,7 +1056,7 @@ Constant *ConstantFoldInstOperandsImpl(c
     return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
   case Instruction::ExtractValue:
     return ConstantExpr::getExtractValue(
-        Ops[0], dyn_cast<ExtractValueInst>(InstOrCE)->getIndices());
+        Ops[0], cast<ExtractValueInst>(InstOrCE)->getIndices());
   case Instruction::InsertElement:
     return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
   case Instruction::ShuffleVector:




More information about the llvm-commits mailing list