aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-04-08 21:56:52 +0000
committerDevang Patel <dpatel@apple.com>2011-04-08 21:56:52 +0000
commit6cf37dd1fd7280dbe4208bab7169ccafc816c768 (patch)
treeb172910b9e339bbe505e7c8add531066b3bce806 /lib/CodeGen/CGDebugInfo.cpp
parent49af1f3cedc55726e4a3dd343eb4a8e24eab8439 (diff)
Do not use zero as an upper bound for unbounded array because upper bound zero also indicates one element array.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 17fc47820c..578ee1a764 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -1235,11 +1235,16 @@ llvm::DIType CGDebugInfo::CreateType(const TagType *Ty) {
llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty,
llvm::DIFile Unit) {
llvm::DIType ElementTy = getOrCreateType(Ty->getElementType(), Unit);
- uint64_t NumElems = Ty->getNumElements();
- if (NumElems > 0)
+ int64_t NumElems = Ty->getNumElements();
+ int64_t LowerBound = 0;
+ if (NumElems == 0)
+ // If number of elements are not known then this is an unbounded array.
+ // Use Low = 1, Hi = 0 to express such arrays.
+ LowerBound = 1;
+ else
--NumElems;
- llvm::Value *Subscript = DBuilder.getOrCreateSubrange(0, NumElems);
+ llvm::Value *Subscript = DBuilder.getOrCreateSubrange(LowerBound, NumElems);
llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(&Subscript, 1);
uint64_t Size = CGM.getContext().getTypeSize(Ty);
@@ -1281,12 +1286,18 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
EltTy = Ty->getElementType();
else {
while ((Ty = dyn_cast<ArrayType>(EltTy))) {
- uint64_t Upper = 0;
+ int64_t UpperBound = 0;
+ int64_t LowerBound = 0;
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty))
if (CAT->getSize().getZExtValue())
- Upper = CAT->getSize().getZExtValue() - 1;
+ 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(0, Upper));
+ Subscripts.push_back(DBuilder.getOrCreateSubrange(LowerBound, UpperBound));
EltTy = Ty->getElementType();
}
}