diff options
author | dim <dim@FreeBSD.org> | 2012-05-27 13:33:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-05-27 13:33:54 +0000 |
commit | a672aabea920d34e84bd86ff013aa294bf6a5f7b (patch) | |
tree | 8c1836512dddde004ff7bb35551f9d06a1689012 /contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 6eca4849e8384847785622b144a8cb065626c4d3 (diff) | |
download | FreeBSD-src-a672aabea920d34e84bd86ff013aa294bf6a5f7b.zip FreeBSD-src-a672aabea920d34e84bd86ff013aa294bf6a5f7b.tar.gz |
Pull in r157212 from upstream clang trunk:
Revert r115805. An array type is required to have a range type,
however, the range can be unknown for the upper bound.
Testcase to follow.
Part of rdar://11457152
This should fix ctfconvert producing error messages during kernel
builds, similar to:
ERROR: scsi_all.c: die 24561: failed to retrieve array bounds
These were caused by incorrect debug information for flexible array
members of structs.
MFC after: 3 days
Diffstat (limited to 'contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp index d286d24..78160f5 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1479,25 +1479,21 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, // obvious/recursive way? SmallVector<llvm::Value *, 8> Subscripts; QualType EltTy(Ty, 0); - if (Ty->isIncompleteArrayType()) + while ((Ty = dyn_cast<ArrayType>(EltTy))) { + int64_t UpperBound = 0; + int64_t LowerBound = 0; + if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) { + if (CAT->getSize().getZExtValue()) + UpperBound = CAT->getSize().getZExtValue() - 1; + } else + // This is an unbounded array. Use Low = 1, Hi = 0 to express such + // arrays. + LowerBound = 1; + + // FIXME: Verify this is right for VLAs. + Subscripts.push_back(DBuilder.getOrCreateSubrange(LowerBound, + UpperBound)); EltTy = Ty->getElementType(); - else { - while ((Ty = dyn_cast<ArrayType>(EltTy))) { - int64_t UpperBound = 0; - int64_t LowerBound = 0; - if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) { - if (CAT->getSize().getZExtValue()) - UpperBound = CAT->getSize().getZExtValue() - 1; - } else - // This is an unbounded array. Use Low = 1, Hi = 0 to express such - // arrays. - LowerBound = 1; - - // FIXME: Verify this is right for VLAs. - Subscripts.push_back(DBuilder.getOrCreateSubrange(LowerBound, - UpperBound)); - EltTy = Ty->getElementType(); - } } llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts); |