aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-09-30 21:08:08 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-09-30 21:08:08 +0000
commit1fb613c43de4dc6d6955be6054a7300de8f2d79b (patch)
tree125cb20ea8f5fa38fed3fe04738e980a39222aab
parent5184635eda68a0cdcd39c958ccc11ba1843bcc7b (diff)
Assert that ConstantArrays are created with correctly-typed elements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83168 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/Constants.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index eb7e7c05fb..2da95b01b0 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -482,6 +482,10 @@ ConstantArray::ConstantArray(const ArrayType *T,
Constant *ConstantArray::get(const ArrayType *Ty,
const std::vector<Constant*> &V) {
+ for (unsigned i = 0, e = V.size(); i != e; ++i) {
+ assert(V[i]->getType() == Ty->getElementType() &&
+ "Wrong type in array element initializer");
+ }
LLVMContextImpl *pImpl = Ty->getContext().pImpl;
// If this is an all-zero array, return a ConstantAggregateZero object
if (!V.empty()) {
@@ -2140,4 +2144,3 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
// Delete the old constant!
destroyConstant();
}
-