strengthen up an assertion: you can't create a constant struct
authorChris Lattner <sabre@nondot.org>
Sun, 7 Aug 2011 04:18:48 +0000 (04:18 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 7 Aug 2011 04:18:48 +0000 (04:18 +0000)
with an opaque struct type, it doesn't make sense.  This should
resolve PR10473.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137028 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 9d0f7cc3c8e029ebd3d85e15d8b1f5abdf7aa6e2..2f22cda5ba4aa0fdf128cd36df0d8fa849e29ab9 100644 (file)
@@ -652,7 +652,7 @@ ConstantStruct::ConstantStruct(StructType *T, ArrayRef<Constant *> V)
   : Constant(T, ConstantStructVal,
              OperandTraits<ConstantStruct>::op_end(this) - V.size(),
              V.size()) {
-  assert((T->isOpaque() || V.size() == T->getNumElements()) &&
+  assert(V.size() == T->getNumElements() &&
          "Invalid initializer vector for constant structure");
   for (unsigned i = 0, e = V.size(); i != e; ++i)
     assert((T->isOpaque() || V[i]->getType() == T->getElementType(i)) &&
@@ -672,7 +672,7 @@ Constant *ConstantStruct::get(StructType *ST, ArrayRef<Constant*> V) {
   return ConstantAggregateZero::get(ST);
 }
 
-ConstantConstantStruct::get(StructType *T, ...) {
+Constant *ConstantStruct::get(StructType *T, ...) {
   va_list ap;
   SmallVector<Constant*, 8> Values;
   va_start(ap, T);