libstdc++-v3 was failing to build. Needed to handle composite types with empty
authorJim Laskey <jlaskey@mac.com>
Wed, 8 Mar 2006 02:07:02 +0000 (02:07 +0000)
committerJim Laskey <jlaskey@mac.com>
Wed, 8 Mar 2006 02:07:02 +0000 (02:07 +0000)
members (running into a zero initializer.)

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

lib/CodeGen/MachineDebugInfo.cpp

index 9e76daa4b78730dab09bb46f002e4bc7d2040d26..45ded8e426eafd3f79c7b40b9e8fa1d3fcadf2e9 100644 (file)
@@ -263,12 +263,15 @@ public:
   virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
     Constant *C = CI->getOperand(I++);
     GlobalVariable *GV = getGlobalVariable(C);
-    ConstantArray *CA = cast<ConstantArray>(GV->getInitializer());
     Field.resize(0);
-    for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
-      GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
-      DebugInfoDesc *DE = DR.Deserialize(GVE);
-      Field.push_back(DE);
+    // Have to be able to deal with the empty array case (zero initializer)
+    if (!GV->hasInitializer()) return;
+    if (ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer())) {
+      for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
+        GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
+        DebugInfoDesc *DE = DR.Deserialize(GVE);
+        Field.push_back(DE);
+      }
     }
   }
 };