Do not emit subrange for incomplete array type.

This is tested by ptype.exp in gdb testsuite.

llvm-svn: 115805
This commit is contained in:
Devang Patel 2010-10-06 18:30:00 +00:00
parent df2dc0f6f2
commit c0601d1e99
1 changed files with 11 additions and 7 deletions

View File

@ -1255,14 +1255,18 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
// obvious/recursive way?
llvm::SmallVector<llvm::DIDescriptor, 8> Subscripts;
QualType EltTy(Ty, 0);
while ((Ty = dyn_cast<ArrayType>(EltTy))) {
uint64_t Upper = 0;
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));
if (Ty->isIncompleteArrayType())
EltTy = Ty->getElementType();
else {
while ((Ty = dyn_cast<ArrayType>(EltTy))) {
uint64_t Upper = 0;
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();
}
}
llvm::DIArray SubscriptArray =