Adjust to the changed StructType interface.  In particular, getElementTypes() is gone.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11228 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp
index 24ccf91..f67d0d6 100644
--- a/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/lib/Analysis/DataStructure/DataStructure.cpp
@@ -241,7 +241,7 @@
         StackState &SS = Stack.back();
         if (const StructType *ST = dyn_cast<StructType>(SS.Ty)) {
           ++SS.Idx;
-          if (SS.Idx != ST->getElementTypes().size()) {
+          if (SS.Idx != ST->getNumElements()) {
             const StructLayout *SL = TD.getStructLayout(ST);
             SS.Offset += SL->MemberOffsets[SS.Idx]-SL->MemberOffsets[SS.Idx-1];
             return;
@@ -266,14 +266,14 @@
       while (!Stack.empty() && !Stack.back().Ty->isFirstClassType()) {
         StackState &SS = Stack.back();
         if (const StructType *ST = dyn_cast<StructType>(SS.Ty)) {
-          if (ST->getElementTypes().empty()) {
+          if (ST->getNumElements() == 0) {
             assert(SS.Idx == 0);
             PopStackAndAdvance();
           } else {
             // Step into the structure...
-            assert(SS.Idx < ST->getElementTypes().size());
+            assert(SS.Idx < ST->getNumElements());
             const StructLayout *SL = TD.getStructLayout(ST);
-            Stack.push_back(StackState(ST->getElementTypes()[SS.Idx],
+            Stack.push_back(StackState(ST->getElementType(SS.Idx),
                                        SS.Offset+SL->MemberOffsets[SS.Idx]));
           }
         } else {
@@ -443,7 +443,7 @@
         /* empty */;
 
       // The offset we are looking for must be in the i'th element...
-      SubType = STy->getElementTypes()[i];
+      SubType = STy->getElementType(i);
       O += SL.MemberOffsets[i];
       break;
     }
@@ -496,7 +496,7 @@
         NextPadSize = SL.MemberOffsets[1];
       else
         NextPadSize = SubTypeSize;
-      NextSubType = STy->getElementTypes()[0];
+      NextSubType = STy->getElementType(0);
       NextSubTypeSize = TD.getTypeSize(NextSubType);
       break;
     }
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 0981eab..ad431d0 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -1085,9 +1085,9 @@
 
     // Check to ensure that constants are compatible with the type initializer!
     for (unsigned i = 0, e = $3->size(); i != e; ++i)
-      if ((*$3)[i]->getType() != STy->getElementTypes()[i])
+      if ((*$3)[i]->getType() != STy->getElementType(i))
         ThrowException("Expected type '" +
-                       STy->getElementTypes()[i]->getDescription() +
+                       STy->getElementType(i)->getDescription() +
                        "' for element #" + utostr(i) +
                        " of structure initializer!");
 
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index e8cebcb..e9e578d 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -233,12 +233,12 @@
 
   case Type::StructTyID: {
     const StructType *ST = cast<StructType>(Ty);
-    const StructType::ElementTypes &ET = ST->getElementTypes();
 
     std::vector<Constant *> Elements;
-    Elements.reserve(ET.size());
-    for (unsigned i = 0; i != ET.size(); ++i)
-      Elements.push_back(getConstantValue(ET[i], read_vbr_uint(Buf, EndBuf)));
+    Elements.reserve(ST->getNumElements());
+    for (unsigned i = 0; i != ST->getNumElements(); ++i)
+      Elements.push_back(getConstantValue(ST->getElementType(i),
+                                          read_vbr_uint(Buf, EndBuf)));
 
     return ConstantStruct::get(ST, Elements);
   }    
diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp
index 6d49165..bb8d286 100644
--- a/lib/Bytecode/Writer/ConstantWriter.cpp
+++ b/lib/Bytecode/Writer/ConstantWriter.cpp
@@ -66,8 +66,8 @@
     const StructType *ST = cast<StructType>(T);
 
     // Output all of the element types...
-    StructType::ElementTypes::const_iterator I = ST->getElementTypes().begin();
-    for (; I != ST->getElementTypes().end(); ++I) {
+    for (StructType::element_iterator I = ST->element_begin(),
+           E = ST->element_end(); I != E; ++I) {
       int Slot = Table.getSlot(*I);
       assert(Slot != -1 && "Type used but not available!!");
       output_vbr((unsigned)Slot, Out);
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index a4b7d8f..be6d435 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -222,9 +222,8 @@
     const StructType *STy = cast<StructType>(Ty);
     Out << NameSoFar + " {\n";
     unsigned Idx = 0;
-    for (StructType::ElementTypes::const_iterator
-           I = STy->getElementTypes().begin(),
-           E = STy->getElementTypes().end(); I != E; ++I) {
+    for (StructType::element_iterator I = STy->element_begin(),
+           E = STy->element_end(); I != E; ++I) {
       Out << "  ";
       printType(Out, *I, "field" + utostr(Idx++));
       Out << ";\n";
@@ -888,9 +887,8 @@
     //Check to see if we have already printed this struct
     if (StructPrinted.count(STy) == 0) {
       // Print all contained types first...
-      for (StructType::ElementTypes::const_iterator
-             I = STy->getElementTypes().begin(),
-             E = STy->getElementTypes().end(); I != E; ++I) {
+      for (StructType::element_iterator I = STy->element_begin(),
+             E = STy->element_end(); I != E; ++I) {
         const Type *Ty1 = I->get();
         if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
           printContainedStructs(*I, StructPrinted);
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index a4b7d8f..be6d435 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -222,9 +222,8 @@
     const StructType *STy = cast<StructType>(Ty);
     Out << NameSoFar + " {\n";
     unsigned Idx = 0;
-    for (StructType::ElementTypes::const_iterator
-           I = STy->getElementTypes().begin(),
-           E = STy->getElementTypes().end(); I != E; ++I) {
+    for (StructType::element_iterator I = STy->element_begin(),
+           E = STy->element_end(); I != E; ++I) {
       Out << "  ";
       printType(Out, *I, "field" + utostr(Idx++));
       Out << ";\n";
@@ -888,9 +887,8 @@
     //Check to see if we have already printed this struct
     if (StructPrinted.count(STy) == 0) {
       // Print all contained types first...
-      for (StructType::ElementTypes::const_iterator
-             I = STy->getElementTypes().begin(),
-             E = STy->getElementTypes().end(); I != E; ++I) {
+      for (StructType::element_iterator I = STy->element_begin(),
+             E = STy->element_end(); I != E; ++I) {
         const Type *Ty1 = I->get();
         if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
           printContainedStructs(*I, StructPrinted);
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 91c9d01..9142f1d 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -42,9 +42,8 @@
   StructSize = 0;
 
   // Loop over each of the elements, placing them in memory...
-  for (StructType::ElementTypes::const_iterator
-	 TI = ST->getElementTypes().begin(), 
-	 TE = ST->getElementTypes().end(); TI != TE; ++TI) {
+  for (StructType::element_iterator TI = ST->element_begin(), 
+	 TE = ST->element_end(); TI != TE; ++TI) {
     const Type *Ty = *TI;
     unsigned char A;
     unsigned TyAlign;
@@ -227,7 +226,7 @@
       Result += Layout->MemberOffsets[FieldNo];
 
       // Update Ty to refer to current element
-      Ty = STy->getElementTypes()[FieldNo];
+      Ty = STy->getElementType(FieldNo);
     }
   }
 
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp
index 45df829..af2544f 100644
--- a/lib/Target/X86/InstSelectSimple.cpp
+++ b/lib/Target/X86/InstSelectSimple.cpp
@@ -2103,7 +2103,7 @@
       }
       // The next type is the member of the structure selected by the
       // index.
-      Ty = StTy->getElementTypes()[idxValue];
+      Ty = StTy->getElementType(idxValue);
     } else if (const SequentialType *SqTy = cast<SequentialType>(Ty)) {
       // It's an array or pointer access: [ArraySize x ElementType].
 
diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp
index 45df829..af2544f 100644
--- a/lib/Target/X86/X86ISelSimple.cpp
+++ b/lib/Target/X86/X86ISelSimple.cpp
@@ -2103,7 +2103,7 @@
       }
       // The next type is the member of the structure selected by the
       // index.
-      Ty = StTy->getElementTypes()[idxValue];
+      Ty = StTy->getElementType(idxValue);
     } else if (const SequentialType *SqTy = cast<SequentialType>(Ty)) {
       // It's an array or pointer access: [ArraySize x ElementType].
 
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index d5bf4c3..ad18bae 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -69,11 +69,10 @@
   }
   case Type::StructTyID: {
     const StructType *ST = cast<StructType>(Ty);
-    const StructType::ElementTypes &El = ST->getElementTypes();
     std::vector<const Type *> Types;
 
-    for (StructType::ElementTypes::const_iterator I = El.begin(), E = El.end();
-         I != E; ++I)
+    for (StructType::element_iterator I = ST->element_begin(),
+           E = ST->element_end(); I != E; ++I)
       Types.push_back(ConvertType(*I));
     DestTy = StructType::get(Types);
     break;
@@ -115,7 +114,7 @@
   if (const StructType *OldST = dyn_cast<StructType>(OldTy)) {
     // Figure out what the current index is...
     unsigned ElNum = cast<ConstantUInt>(Idx[i])->getValue();
-    assert(ElNum < OldST->getElementTypes().size());
+    assert(ElNum < OldST->getNumElements());
 
     std::map<const StructType*, TransformType>::iterator
       I = Transforms.find(OldST);
@@ -198,7 +197,7 @@
     const StructType  *OldTy = I->first;
     const std::vector<int> &InVec = I->second;
 
-    assert(OldTy->getElementTypes().size() == InVec.size() &&
+    assert(OldTy->getNumElements() == InVec.size() &&
            "Action not specified for every element of structure type!");
 
     std::vector<const Type *> NewType;
diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp
index 809ca40..f2061dd 100644
--- a/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/lib/Transforms/IPO/SimpleStructMutation.cpp
@@ -109,7 +109,7 @@
 static inline void GetTransformation(const TargetData &TD, const StructType *ST,
                                      std::vector<int> &Transform,
                                    enum SimpleStructMutation::Transform XForm) {
-  unsigned NumElements = ST->getElementTypes().size();
+  unsigned NumElements = ST->getNumElements();
   Transform.reserve(NumElements);
 
   switch (XForm) {
@@ -124,8 +124,7 @@
 
     // Build mapping from index to size
     for (unsigned i = 0; i < NumElements; ++i)
-      ElList.push_back(
-              std::make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
+      ElList.push_back(std::make_pair(i,TD.getTypeSize(ST->getElementType(i))));
 
     sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess));
 
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index 12268ed..edc42b7 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -375,12 +375,12 @@
             const Type *IdxType;
             if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
               // Check for a zero element struct type... if we have one, bail.
-              if (CurSTy->getElementTypes().size() == 0) break;
+              if (CurSTy->getNumElements() == 0) break;
             
               // Grab the first element of the struct type, which must lie at
               // offset zero in the struct.
               //
-              ElTy = CurSTy->getElementTypes()[0];
+              ElTy = CurSTy->getElementType(0);
               IdxType = Type::UByteTy;   // FIXME when PR82 is fixed.
             } else {
               ElTy = cast<ArrayType>(CurCTy)->getElementType();
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp
index eb20544..9039f59 100644
--- a/lib/Transforms/TransformInternals.cpp
+++ b/lib/Transforms/TransformInternals.cpp
@@ -62,7 +62,7 @@
   uint64_t ThisOffset;
   const Type *NextType;
   if (const StructType *STy = dyn_cast<StructType>(Ty)) {
-    if (STy->getElementTypes().empty()) {
+    if (STy->getNumElements()) {
       Offset = 0;
       return STy;
     }
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 3ed2312..5fc7a89 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -169,10 +169,9 @@
   case Type::StructTyID: {
     const StructType *STy = cast<StructType>(Ty);
     Result = "{ ";
-    for (StructType::ElementTypes::const_iterator
-           I = STy->getElementTypes().begin(),
-           E = STy->getElementTypes().end(); I != E; ++I) {
-      if (I != STy->getElementTypes().begin())
+    for (StructType::element_iterator I = STy->element_begin(),
+           E = STy->element_end(); I != E; ++I) {
+      if (I != STy->element_begin())
         Result += ", ";
       Result += calcTypeName(*I, TypeStack, TypeNames);
     }
@@ -529,10 +528,9 @@
     Out << ")";
   } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
     Out << "{ ";
-    for (StructType::ElementTypes::const_iterator
-           I = STy->getElementTypes().begin(),
-           E = STy->getElementTypes().end(); I != E; ++I) {
-      if (I != STy->getElementTypes().begin())
+    for (StructType::element_iterator I = STy->element_begin(),
+           E = STy->element_end(); I != E; ++I) {
+      if (I != STy->element_begin())
         Out << ", ";
       printType(*I);
     }
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index caeb8cd..2500ec4 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -118,11 +118,10 @@
 
   case Type::StructTyID: {
     const StructType *ST = cast<StructType>(Ty);
-    const StructType::ElementTypes &ETs = ST->getElementTypes();
     std::vector<Constant*> Elements;
-    Elements.resize(ETs.size());
-    for (unsigned i = 0, e = ETs.size(); i != e; ++i)
-      Elements[i] = Constant::getNullValue(ETs[i]);
+    Elements.resize(ST->getNumElements());
+    for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i)
+      Elements[i] = Constant::getNullValue(ST->getElementType(i));
     return ConstantStruct::get(ST, Elements);
   }
   case Type::ArrayTyID: {
@@ -263,14 +262,15 @@
 
 ConstantStruct::ConstantStruct(const StructType *T,
                                const std::vector<Constant*> &V) : Constant(T) {
-  const StructType::ElementTypes &ETypes = T->getElementTypes();
-  assert(V.size() == ETypes.size() &&
+  assert(V.size() == T->getNumElements() &&
          "Invalid initializer vector for constant structure");
   Operands.reserve(V.size());
   for (unsigned i = 0, e = V.size(); i != e; ++i) {
-    assert((V[i]->getType() == ETypes[i] ||
-            ((ETypes[i]->isAbstract() || V[i]->getType()->isAbstract()) &&
-             ETypes[i]->getPrimitiveID()==V[i]->getType()->getPrimitiveID())) &&
+    assert((V[i]->getType() == T->getElementType(i) ||
+            ((T->getElementType(i)->isAbstract() ||
+              V[i]->getType()->isAbstract()) &&
+             T->getElementType(i)->getPrimitiveID() == 
+                      V[i]->getType()->getPrimitiveID())) &&
            "Initializer for struct element doesn't match struct element type!");
     Operands.push_back(Use(V[i], this));
   }
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 7738955..d649d08 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -206,10 +206,9 @@
   case Type::StructTyID: {
     const StructType *STy = cast<StructType>(Ty);
     Result = "{ ";
-    for (StructType::ElementTypes::const_iterator
-           I = STy->getElementTypes().begin(),
-           E = STy->getElementTypes().end(); I != E; ++I) {
-      if (I != STy->getElementTypes().begin())
+    for (StructType::element_iterator I = STy->element_begin(),
+           E = STy->element_end(); I != E; ++I) {
+      if (I != STy->element_begin())
         Result += ", ";
       Result += getTypeDescription(*I, TypeStack);
     }
@@ -512,12 +511,10 @@
     return TypesEqual(PTy->getElementType(),
                       cast<PointerType>(Ty2)->getElementType(), EqTypes);
   } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
-    const StructType::ElementTypes &STyE = STy->getElementTypes();
-    const StructType::ElementTypes &STyE2 =
-      cast<StructType>(Ty2)->getElementTypes();
-    if (STyE.size() != STyE2.size()) return false;
-    for (unsigned i = 0, e = STyE.size(); i != e; ++i)
-      if (!TypesEqual(STyE[i], STyE2[i], EqTypes))
+    const StructType *STy2 = cast<StructType>(Ty2);
+    if (STy->getNumElements() != STy2->getNumElements()) return false;
+    for (unsigned i = 0, e = STy2->getNumElements(); i != e; ++i)
+      if (!TypesEqual(STy->getElementType(i), STy2->getElementType(i), EqTypes))
         return false;
     return true;
   } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
@@ -815,9 +812,9 @@
 
   static StructValType get(const StructType *ST) {
     std::vector<const Type *> ElTypes;
-    ElTypes.reserve(ST->getElementTypes().size());
-    for (unsigned i = 0, e = ST->getElementTypes().size(); i != e; ++i)
-      ElTypes.push_back(ST->getElementTypes()[i]);
+    ElTypes.reserve(ST->getNumElements());
+    for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i)
+      ElTypes.push_back(ST->getElementType(i));
     
     return StructValType(ElTypes);
   }