[cfe-commits] r129157 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Devang Patel
dpatel at apple.com
Fri Apr 8 14:56:52 PDT 2011
Author: dpatel
Date: Fri Apr 8 16:56:52 2011
New Revision: 129157
URL: http://llvm.org/viewvc/llvm-project?rev=129157&view=rev
Log:
Do not use zero as an upper bound for unbounded array because upper bound zero also indicates one element array.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=129157&r1=129156&r2=129157&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 8 16:56:52 2011
@@ -1235,11 +1235,16 @@
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 @@
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();
}
}
More information about the cfe-commits
mailing list