IR: Add missing assertion for ConstantVector::ConstantVector

Use the same assertion as ConstantArray.  Vectors should have the right
number of elements.

llvm-svn: 265463
This commit is contained in:
Duncan P. N. Exon Smith
2016-04-05 20:53:47 +00:00
parent 639a333730
commit db63bda88d

View File

@@ -1036,6 +1036,8 @@ ConstantVector::ConstantVector(VectorType *T, ArrayRef<Constant *> V)
: Constant(T, ConstantVectorVal,
OperandTraits<ConstantVector>::op_end(this) - V.size(),
V.size()) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer vector for constant vector");
for (size_t i = 0, e = V.size(); i != e; i++)
assert(V[i]->getType() == T->getElementType() &&
"Initializer for vector element doesn't match vector element type!");