[llvm-commits] [llvm] r83168 - /llvm/trunk/lib/VMCore/Constants.cpp
Jeffrey Yasskin
jyasskin at google.com
Wed Sep 30 14:08:08 PDT 2009
Author: jyasskin
Date: Wed Sep 30 16:08:08 2009
New Revision: 83168
URL: http://llvm.org/viewvc/llvm-project?rev=83168&view=rev
Log:
Assert that ConstantArrays are created with correctly-typed elements.
Modified:
llvm/trunk/lib/VMCore/Constants.cpp
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=83168&r1=83167&r2=83168&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Wed Sep 30 16:08:08 2009
@@ -482,6 +482,10 @@
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 @@
// Delete the old constant!
destroyConstant();
}
-
More information about the llvm-commits
mailing list