Fix a bug that was found by the clang static analyzer. The var "AT" is null so we...
authorNadav Rotem <nrotem@apple.com>
Tue, 19 Feb 2013 19:36:59 +0000 (19:36 +0000)
committerNadav Rotem <nrotem@apple.com>
Tue, 19 Feb 2013 19:36:59 +0000 (19:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175550 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/ConstantFold.cpp

index 587b7ce88a9dec5665f2845f71923451762cdad6..a5a9d9f3a7c901d3ad5ef024fa0ef01f35b1270a 100644 (file)
@@ -846,8 +846,8 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg,
   else if (ArrayType *AT = dyn_cast<ArrayType>(Agg->getType()))
     NumElts = AT->getNumElements();
   else
-    NumElts = AT->getVectorNumElements();
-  
+    NumElts = Agg->getType()->getVectorNumElements();
+
   SmallVector<Constant*, 32> Result;
   for (unsigned i = 0; i != NumElts; ++i) {
     Constant *C = Agg->getAggregateElement(i);