diff options
| author | Bill Wendling <isanbard@gmail.com> | 2012-12-04 21:33:58 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2012-12-04 21:33:58 +0000 |
| commit | 751afdc3d1583dab43064892c90eb864cd69cd37 (patch) | |
| tree | e12ca5cc3c089e369e3d3cd34b74569536ab0858 /clang/lib/CodeGen | |
| parent | 35439dff76c4c6ccbed39182ba818ecbca179dac (diff) | |
| download | bcm5719-llvm-751afdc3d1583dab43064892c90eb864cd69cd37.tar.gz bcm5719-llvm-751afdc3d1583dab43064892c90eb864cd69cd37.zip | |
Use the 'count' attribute to calculate the upper bound of an array.
The count attribute is more accurate with regards to the size of an array. It
also obviates the upper bound attribute in the subrange. We can also better
handle an unbound array by setting the count to -1 instead of the lower bound to
1 and upper bound to 0.
llvm-svn: 169311
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index a4182afd1e4..f3468f29c1b 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1473,25 +1473,19 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) { llvm::DIType ElementTy = getOrCreateType(Ty->getElementType(), Unit); - int64_t NumElems = Ty->getNumElements(); - int64_t LowerBound = 0; - int64_t Count = NumElems; - if (NumElems == 0) + int64_t Count = Ty->getNumElements(); + if (Count == 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; + // Use Count == -1 to express such arrays. + Count = -1; - llvm::Value *Subscript = DBuilder.getOrCreateSubrange(LowerBound, NumElems, - Count); + llvm::Value *Subscript = DBuilder.getOrCreateSubrange(0, Count); llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(Subscript); uint64_t Size = CGM.getContext().getTypeSize(Ty); uint64_t Align = CGM.getContext().getTypeAlign(Ty); - return - DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); + return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); } llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, @@ -1532,23 +1526,12 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, // struct foo { // int x[0]; // }; - int64_t UpperBound = 0; - int64_t LowerBound = 0; - int64_t Count = -1; - if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) { + int64_t Count = -1; // Count == -1 is an unbounded array. + if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty)) Count = CAT->getSize().getZExtValue(); - if (Count) - UpperBound = Count - 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, - Count)); + Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count)); EltTy = Ty->getElementType(); } |

