]> granicus.if.org Git - clang/commitdiff
Do now overflow while calulating upper bound for zero sized array.
authorDevang Patel <dpatel@apple.com>
Fri, 14 Aug 2009 20:57:45 +0000 (20:57 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 14 Aug 2009 20:57:45 +0000 (20:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79043 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index ee2a94067d3c32bd950efd711597b056bb4b271d..6547434883437b770d7bb7cdd1d8e7298ec58be5 100644 (file)
@@ -722,8 +722,9 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
   QualType EltTy(Ty, 0);
   while ((Ty = dyn_cast<ArrayType>(EltTy))) {
     uint64_t Upper = 0;
-    if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty))
-      Upper = CAT->getSize().getZExtValue() - 1;
+    if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) 
+      if (CAT->getSize().getZExtValue())
+       Upper = CAT->getSize().getZExtValue() - 1;
     // FIXME: Verify this is right for VLAs.
     Subscripts.push_back(DebugFactory.GetOrCreateSubrange(0, Upper));
     EltTy = Ty->getElementType();